2012-08-04 81 views
0

我無法從我的Umbraco網站發佈RSS提要。我發現this Umbraco.TV視頻,並試圖按照指示使用XSLT選擇器選擇一個給定類型的所有節點,就像這樣:發佈RSS提要的問題

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

由於sugested here,但沒有奏效。顯然the schema has changed什麼的。當這不起作用時,我尋找一個插件來做這種事情,很驚訝地發現只有2個插件,他們兩個都沒有文檔,也沒有工作(first pluginsecond plugin)。

因此,我希望得到一個明確的答案 - 如何在Umbraco中發佈RSS feed?

回答

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>