Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mikael Mørup 297 posts 326 karma points
    Sep 18, 2009 @ 16:10
    Mikael Mørup
    0

    Hooking into the RSS button in FF and IE

    In both IE (8) and FF (3.5) there are an RSS button in the toolbar that "automatically" finds RSSfeeds on some sites / pages, and shows them "feed style" when clicked.

    Does anybody know how this button works, and how to implement that functionality for an Umbraco based site / page. It looks like you somehow can give it  a URL that lnks to a feed. But how is that acomplished ?

    Thanks

    Mikael

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Sep 18, 2009 @ 16:18
    Dave Woestenborghs
    0

    Hi Mikael,

    You can do this by adding following code to the head tag of your page :

    <link rel="alternate" type="application/rss+xml" title="Umbraco News " href="/NewsRss.aspx" />

    You can more "links" to different RSS feeds.

     

    Dave

     

  • dandrayne 1138 posts 2262 karma points
    Sep 18, 2009 @ 16:22
    dandrayne
    0

    Hi There

    A link in the head of the document does this, along the lines of

    <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="/path/to/rssTemplate.aspx" />

    Then you just need a template to produce an rss feed from your xml.

    Can't remember where I got this xslt (prob from the excellent CWS), but here's a xsl sheet to do something like this

    Template (macro insert code) (v3 embed code, will work with small mod for v3)

    <?UMBRACO_MACRO macroAlias="XSLTRSSFeed" RSSNoItems="[#RSSNoItems]" RSSTitle="[#RSSTitle]" SiteURL="[#SiteURL]" RSSDescription="[#RSSDescription]"></?UMBRACO_MACRO>

    You'll need to change the nodeTypeAlias's that you're searching for in the file below, but it's a good start!

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


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

    <xsl:param name="currentPage"/>

    <!-- Variables to pull in from macro & node -->
    <xsl:variable name="RSSNoItems" select="/macro/RSSNoItems"/>
    <xsl:variable name="RSSTitle" select="/macro/RSSTitle"/>
    <xsl:variable name="SiteURL" select="/macro/SiteURL"/>
    <xsl:variable name="RSSDescription" select="/macro/RSSDescription"/>
    <xsl:variable name="SortOrder" select="$currentPage/data [@alias = 'SortOrder']" />
    <xsl:variable name="SortBy" select="$currentPage/data [@alias = 'SortBy']" />


    <xsl:variable name="DataType">
    <xsl:choose>
    <xsl:when test="$SortBy='sortOrder'">
    <xsl:value-of select="'number'" />
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="'text'" />
    </xsl:otherwise>
    </xsl:choose>
    </xsl:variable>


    <!-- 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="$currentPage/node ">
    <xsl:sort select="@updateDate" data-type="text" order="descending" />
    <xsl:if test="position() = 1">
    <xsl:value-of select="updateDate" />
    </xsl:if>
    </xsl:for-each>
    </xsl:variable>

    <xsl:template match="/">
    <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 2.1.6</generator>
    <description><xsl:value-of select="$RSSDescription"/></description>
    <language>en</language>

    <xsl:apply-templates select="$currentPage/ancestor-or-self::node[@level=1]/descendant::node [@nodeTypeAlias = 'NewsListPage']/node [string(data [@alias='umbracoNaviHide']) != '1' and @nodeTypeAlias != 'NewsFolder']">
    <xsl:sort select="@*[name() = $SortBy]" order="{$SortOrder}" data-type="{$DataType}"/>
    </xsl:apply-templates>
    </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>@updateDate</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[ ', ./data [@alias='bodyText'],']]&gt;')" disable-output-escaping="yes"/></content:encoded>
    </item>
    </xsl:if>
    </xsl:template>

    </xsl:stylesheet>

     

     

    Dan

  • dandrayne 1138 posts 2262 karma points
    Sep 18, 2009 @ 16:24
    dandrayne
    0

    Also should mention the macro params for this

    RSSNoItems - number
    RSSTitle - text
    RSSDescription - textmultiline
    SiteURL - text

    Good luck!

  • Mikael Mørup 297 posts 326 karma points
    Sep 18, 2009 @ 22:35
    Mikael Mørup
    0

    Thanks to both of you.

    i already have my own user control to generate the XML for the feed, because the selection of nodes / pages is not as straight forward as the sample XSLT that comes with umbraco. So with your info on how to put the link in the page i should be all set.

    Mikael

Please Sign in or register to post replies

Write your reply to:

Draft