0

我在从我的 Umbraco 站点发布 RSS 提要时遇到问题。我找到了这个Umbraco.TV 视频并尝试按照那里的说明使用 XSLT 选择器选择给定类型的所有节点,如下所示:

umbraco.library.GetXmlAll()/node [@nodeTypeAlias='Alias]/node

正如这里所建议的那样,但这没有用。显然架构已经改变或什么。当这不起作用时,我寻找一个插件来做这种事情,并惊讶地发现只有 2 个插件,它们都几乎没有文档,而且似乎都不起作用(第一个插件第二个插件)。

因此,一劳永逸地,我想有一个明确的答案——如何在 Umbraco 中发布 RSS 提要?

4

1 回答 1

0

这是我们用于新闻项目 RSS 的 XSLT(新闻项目位于新闻页面下)。让我知道这是否有帮助。我也有博客的版本。

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:rssdatehelper="urn:rssdatehelper"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:msxml="urn:schemas-microsoft-com:xslt" 
  xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" 
  exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">


  <xsl:output method="xml" omit-xml-declaration="yes"/>

  <xsl:param name="currentPage"/>

  <!-- Update these variables to modify the feed -->
  <xsl:variable name="RSSNoItems" select="/macro/RSSNoItems"/>
  <xsl:variable name="RSSTitle" select="/macro/RSSTitle"/>
  <xsl:variable name="SiteURL" select="concat('http://',umbraco.library:RequestServerVariables('HTTP_HOST'))"/>
  <xsl:variable name="RSSDescription" select="/macro/RSSDescription"/>
  <xsl:variable name="source" select="/macro/source"/>

  <!-- This gets all news and events and orders by updateDate to use for the pubDate in RSS feed -->
  <xsl:variable name="pubDate">
    <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']">
      <xsl:sort select="./newsDate" order="descending" />
      <xsl:if test="position() = 1">
        <xsl:value-of select="./newsDate" />
      </xsl:if>
    </xsl:for-each>
  </xsl:variable>

  <xsl:template match="/">
    <!-- change the mimetype for the current page to xml -->
    <xsl:value-of select="umbraco.library:ChangeContentType('text/xml')"/>

    <xsl:text disable-output-escaping="yes">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</xsl:text>
    <rss version="2.0"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
>

      <channel>
        <title>
          <xsl:value-of select="$RSSTitle"/>
        </title>
        <link>
          <xsl:value-of select="$SiteURL"/>
        </link>
        <pubDate>
          <xsl:value-of select="$pubDate"/>
        </pubDate>
        <generator>umbraco v4</generator>
        <description>
          <xsl:value-of select="$RSSDescription"/>
        </description>
        <language>en</language>

  <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']"> 
  <xsl:sort select="./newsDate" order="descending" />
      <xsl:if test="position() &lt;= $RSSNoItems"> 
    <xsl:call-template name="RSSitem">
                    <xsl:with-param name="node" select="current()"/>
                </xsl:call-template> 
      </xsl:if> 
  </xsl:for-each> 
      </channel>
    </rss>

  </xsl:template>

  <xsl:template match="node">
    <xsl:if test="position() &lt;= $RSSNoItems">
      <item>
        <title>
          <xsl:value-of select="@nodeName"/>
        </title>
        <link>
          <xsl:value-of select="$SiteURL"/>
          <xsl:value-of select="umbraco.library:NiceUrl(@id)"/>
        </link>
        <pubDate>
          <xsl:value-of select="umbraco.library:FormatDateTime(./newsDate,'r')" />
        </pubDate>
        <guid>
          <xsl:value-of select="$SiteURL"/>
          <xsl:value-of select="umbraco.library:NiceUrl(@id)"/>
        </guid>
        <content:encoded>
          <xsl:value-of select="concat('&lt;![CDATA[ ', ./bodyText,']]&gt;')" disable-output-escaping="yes"/>
        </content:encoded>
      </item>
    </xsl:if>
  </xsl:template>


    <xsl:template name="RSSitem">
        <xsl:param name="node"/>
        <item>
            <title>
                <xsl:value-of select="$node/@nodeName"/>
            </title>
            <link>
                <xsl:value-of select="$SiteURL"/><xsl:value-of select="umbraco.library:NiceUrl($node/@id)"/>
            </link>
            <pubDate>
                <xsl:value-of select="umbraco.library:FormatDateTime(./newsDate,'r')"/>
            </pubDate>
            <dc:creator><xsl:value-of select="@writerName"/></dc:creator>
            <xsl:for-each select="umbraco.library:Split($node/categories, ',')/value">
                <xsl:sort data-type="text" order="ascending"/>
                <category>
                    <xsl:value-of select="current()"/>
                </category>               
            </xsl:for-each>
            <guid>
                <xsl:value-of select="$SiteURL"/><xsl:value-of select="umbraco.library:NiceUrl($node/@id)"/>
            </guid>
            <description>
                <xsl:value-of select="concat('&lt;![CDATA[ ', $node/summary,']]&gt;')" disable-output-escaping="yes"/>
            </description>
            <content:encoded>
                <xsl:value-of select="concat('&lt;![CDATA[ ', $node/bodyText,']]&gt;')" disable-output-escaping="yes"/>
            </content:encoded>
        </item>       
    </xsl:template> 

</xsl:stylesheet>
于 2012-08-06T23:35:09.973 回答