简体   繁体   English

在Umbraco中显示最新条目

[英]Displaying latest entries in Umbraco

I'm new to Xslt and Umbraco. 我是Xslt和Umbraco的新手。

I'm trying to fetch the latest, say for example 4, entries from my umbraco database and display them on the homepage. 我正在尝试从umbraco数据库中获取最新的条目(例如4),并将其显示在首页上。 There is an image, title, date, and body that are entered in content tab, in a page, which should be assosiated with eachother. 在页面的内容选项卡中输入的图像,标题,日期和正文应相互关联。

Using Xslt, how do I go about firstly, associating the image, title, date, and body text with eachother. 首先使用Xslt,如何将图像,标题,日期和正文文本相互关联。 And Secondly, displaying the latest descending entries by date? 其次,按日期显示最新降序输入?

You create a doc type (this contains the metadata of the nodes like image, title, body, date); 您创建一个doc类型(其中包含图像,标题,正文,日期等节点的元数据); then create a template which contains the markup interspersed with the content placeholders (the umbraco:item or umbraco:macro bits). 然后创建一个模板,其中包含散布在内容占位符中的标记(umbraco:item或umbraco:macro位)。

Add a macro that contains your xslt to show the last four items; 添加一个包含xslt的宏以显示最后四个项目; and put that macro in the template. 并将该宏放入模板中。

Then create some content node based on this doc type/template (in many cases the doc type to template ratio is 1:1). 然后根据此文档类型/模板创建一些内容节点(在许多情况下,文档类型与模板的比例为1:1)。

In those content nodes you can then specify the contents of those fields you set up in the doc type. 然后,您可以在那些内容节点中指定您在doc类型中设置的那些字段的内容。

I don't do any xslt any more - I only use razor in macros - but your macro would look something like: 我不再做任何xslt-我只在宏中使用剃刀-但您的宏看起来像这样:

  <xsl:for-each select="$currentPage/descendant-or-self::node [@nodeTypeAlias='itemType']">
    <xsl:sort select="data[@alias='createdDate']" order="descending" />
    <xsl:if test="position() &lt;= 4">
      <xsl:value-of select="@title" />
    </xsl:if>
  </xsl:for-each>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM