Copied to clipboard

Flag this post as spam?

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


  • Garrett Fisher 341 posts 496 karma points
    Jan 26, 2010 @ 21:02
    Garrett Fisher
    0

    RSS Feed(s)

    I am gettnig an RSS auto-detect on every page of my site.  The little orange RSS icon in my address bar in Firefox.  But when I click on it, I get a Page not Found error (RSS.aspx).  What's with that?  What exactly is Supposed to happen when I click on this?  What am I supposed to be subscribing to?  How to I configure/implement RSS feeds in Umbraco?

    Thanks,

    Garrett

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Jan 26, 2010 @ 21:14
    Sebastiaan Janssen
    0

    I think the RSS.aspx is something that must've come with Blog4Umbraco or CWS.

    If you had a template called RSS, this would be called when getting RSS.aspx. Do you still have the RSSFeed XSLT file?

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Jan 26, 2010 @ 21:21
    Nik Wahlberg
    1

    The purpoe of the button in your browser is to display any feed(s) that you have generated from your site content. So, if you have someting like this in your <head> tag:

    <link rel="alternate" type="application/rss+xml" title="RSS" href="http://www.yourdomain.com/Rss.apsx">

    Than that would be "activating" the RSS icon. 

    HTH,
    Nik

  • Garrett Fisher 341 posts 496 karma points
    Jan 26, 2010 @ 23:07
    Garrett Fisher
    0

    Yes, I have the RSS XSLT, as well as the template.  Do I need to create a page which utilizes this template in order to make it work?

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Jan 27, 2010 @ 03:58
    Nik Wahlberg
    0

    That is correct. Whatever the URL is of the page that holds your valid RSS 2.0 or Atom feed, is what you would then specify in the header link tag.

  • Garrett Fisher 341 posts 496 karma points
    Jan 27, 2010 @ 20:56
    Garrett Fisher
    0

    It's still not working.

    I have a page, called RSS.aspx, which uses the RSS template.  Inside this template, I have the following Macro:

    <umbraco:Macro rssNoItems="10" rssTitle="GTP News" rssDescription="This is a list of Your Company's news and events that are going on." Alias="NewsRSS" runat="server"></umbraco:Macro>

    The "NewsRSS" template uses the NewsRSS.xslt file, whose loop looks like the following:

    <xsl:for-each select="$currentPage/descendant::node">
    ...
    </xsl:for-each>

    Because I want everything nuder the current page.  However, when I browse to RSS.aspx, nothing shows up in the feed.  What am I doing wrong?

    Thanks again,

    Garrett

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Jan 28, 2010 @ 09:30
    Sebastiaan Janssen
    1

    You don't have to have a node in the content section that is called RSS. There's a neat little trick that Umbraco does: if it can't find the node that you're trying to access, it looks in the Templates section to see if there's a template with that same name.

    My RSS template looks like this (careful, do not start the "<umbraco:Macro" part on a new line, it will invalidate the XML: 

    <%@ Master Language="C#" MasterPageFile="/umbraco/masterpages/default.master" AutoEventWireup="true" %>
    <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server"><umbraco:Macro Alias="BlogRss" runat="server"></umbraco:Macro>
    </asp:Content>

    I've customized the XSLT file for my RSS feed, but you should be able to use it directly (maybe I should make a package for this..) The DocumentType for your blog should be called "Blog" Anything under a node with the DocumentType of Blog will appear in your RSS feed (you can change the blogRoot variable if you called yours something else).

    <?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/"
    xmlns:tagsLib="urn:tagsLib"
    exclude-result-prefixes="msxml umbraco.library tagsLib">
    
    
      <xsl:output method="xml" omit-xml-declaration="yes"/>
    
      <xsl:param name="currentPage"/>
      <xsl:variable name="currentSiteRoot" select="$currentPage/ancestor-or-self::node" />
      <xsl:variable name="blogRoot" select="umbraco.library:GetXmlNodeById($currentSiteRoot//node[@nodeTypeAlias = 'Blog']/@id)"/>
    
      <xsl:variable name="urlPrefix">
        <xsl:text>http://</xsl:text>;
        <xsl:value-of select="umbraco.library:RequestServerVariables('HTTP_HOST')" />
      </xsl:variable>
    
      <!-- Update these variables to modify the feed -->
      <xsl:variable name="rssNoItems" select="string('10')"/>
      <xsl:variable name="rssTitle" select="$blogRoot/data [@alias = 'blogName']"/>
      <xsl:variable name="siteUrl" select="$urlPrefix"/>
      <xsl:variable name="rssDescription" select="$blogRoot/data [@alias = 'blogDescription']"/>
    
      <!-- 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="$blogRoot//node [@nodeTypeAlias = 'BlogPost']">
          <xsl:sort select="@createDate" data-type="text" order="descending" />
          <xsl:if test="position() = 1">
            <xsl:value-of select="umbraco.library:FormatDateTime(@createDate,'r')" />
          </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</generator>
            <description>
              <xsl:value-of select="$rssDescription"/>
            </description>
            <language>en</language>
    
            <xsl:apply-templates select="$blogRoot//node [@nodeTypeAlias = 'BlogPost']">
              <xsl:sort select="@createDate" order="descending" />
            </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>
        <author>
              <xsl:value-of select="@creatorName"/>
        </author>
            <link>
              <xsl:value-of select="$siteUrl"/>
              <xsl:value-of select="umbraco.library:NiceUrl(@id)"/>
            </link>
            <pubDate>
              <xsl:value-of select="umbraco.library:FormatDateTime(@createDate,'r')" />
            </pubDate>
            <guid>
              <xsl:value-of select="$siteUrl"/>
              <xsl:value-of select="umbraco.library:NiceUrl(@id)"/>
            </guid>
        <xsl:for-each select="tagsLib:getTagsFromNode(@id)/tags/tag">
            <category>
                <xsl:value-of select="."/>
            </category>
        </xsl:for-each>
            <content:encoded>
              <xsl:value-of select="concat('&lt;![CDATA[ ', umbraco.library:Replace(./data [@alias='bodyText'], '/media/', concat($siteUrl, '/media/')),']]&gt;')" disable-output-escaping="yes"/>
            </content:encoded>
            <description>
              <xsl:value-of select="concat('&lt;![CDATA[ ', umbraco.library:Replace(./data [@alias='bodyText'], '/media/', concat($siteUrl, '/media/')),']]&gt;')" disable-output-escaping="yes"/>
            </description>
          </item>
        </xsl:if>
      </xsl:template>
    
    </xsl:stylesheet>
  • Laurence Gillian 600 posts 1219 karma points
    May 26, 2010 @ 19:12
    Laurence Gillian
    0

    Doing this will surely create a validation error, as there are 3 lines of whitespace before the macro?

    This seems to be something which happens when you output using masterpages.

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    May 26, 2010 @ 19:27
    Morten Bock
    1

    You should be able to eliminate those be removing the linebreaks in the masterpage/xslt file.

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    May 26, 2010 @ 20:02
    Sebastiaan Janssen
    1

    Yes, it's why I stuck the asp:content and the umbraco:macro together on one line. There's absolutely no whitespacing at the top of my rss feed.

  • Laurence Gillian 600 posts 1219 karma points
    May 26, 2010 @ 20:39
    Laurence Gillian
    0

    Ah simple! :) Good to have it documented in the thread though :)

    Also

     xmlns:rssdatehelper="urn:rssdatehelper"

    Will cause a validation issue as that isn't a valid urn.

  • Laurence Gillian 600 posts 1219 karma points
    May 26, 2010 @ 20:40
    Laurence Gillian
    0

    Plus the way the dates are formated will cause different feed readers to read the data differently. I will look at solutions for these and post an updated XSLT file. Thanks, /L

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    May 26, 2010 @ 21:30
    Morten Bock
    0

    Doesn't this do the job?

    umbraco.library:FormatDateTime(@createDate,'r')

    I ssem to remember that formats it correctly, like 2010-05-26T12:00:00

  • Laurence Gillian 600 posts 1219 karma points
    May 28, 2010 @ 19:12
    Laurence Gillian
    0

    Yep, that format is not RFC822 ;) The correct format looks like below;

    <pubDate>Wed, 02 Oct 2002 08:00:00 EST</pubDate>

    <pubDate>Wed, 02 Oct 2002 13:00:00 GMT</pubDate>

    <pubDate>Wed, 02 Oct 2002 15:00:00 +0200</pubDate>

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    May 28, 2010 @ 19:29
    Morten Bock
    0

    Just looked at the source, and my previous sample should actually output just that. I remembered wrong before.

    The extenstion is implemented like this:

    public static string FormatDateTime(string Date, string Format)
    {
        DateTime result;
        if (DateTime.TryParse(Date, out result))
            return result.ToString(Format);
        return string.Empty;
    }

    And the DateTime.ToString("r") should give you the correct format.

    Are you experiencing something else?

  • DCH 18 posts 38 karma points
    Jul 07, 2010 @ 15:46
    DCH
    0

    to LaurenceG,

    to make get rid of the - xmlns:rssdatehelper="urn:rssdatehelper"

    you can add it to the top of the stylesheet declaration:

    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltStrings BlogLibrary rssdatehelper"

    hope this helps...

Please Sign in or register to post replies

Write your reply to:

Draft