Copied to clipboard

Flag this post as spam?

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


  • Stephen 204 posts 246 karma points
    Sep 05, 2011 @ 11:52
    Stephen
    0

    Rss feed not displaying items

    I'm using a modified version of the NewsEventsRSS.xslt to dislay news items in Rss format and whlist i can get the Title and description to display the items wont...

    http://www.davidorrgolfcoaching.com/do_RSS.aspx

    The code was easy to follow and I'm sure i have it right...

    <?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"/>

        <!-- Update these variables to modify the feed -->
        <xsl:variable name="siteURL"          select="concat('http://www.davidorrgolfcoaching.com/',umbraco.library:RequestServerVariables('HTTP_HOST'))"/>
        <xsl:variable name="rssNoItems"       select="/macro/rssNoItems"/>    
        <xsl:variable name="rssTitle"         select="/macro/rssTitle"/>
        <xsl:variable name="rssDescription"   select="/macro/rssDescription"/>

        <!-- Root Node -->
        <xsl:variable name="rootNode" select="$currentPage/ancestor-or-self::root" />

        <!-- Homepage -->
          <xsl:variable name="homeNode" select="$rootNode/doHome [@isDoc]" />

        <!-- This gets all news and orders by updateDate to use for the pubDate in RSS feed -->
        <xsl:variable name="pubDate">
            <xsl:for-each select="$homeNode//doNews/* [@isDoc]">
                <xsl:sort select="@createDate" 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="/">
            <!-- 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="$homeNode//doNews/* [@isDoc]">
                        <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>
                    <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>
                    <content:encoded>
                        <xsl:value-of select="concat('&lt;![CDATA[ ', current()/bodyText,']]&gt;')" disable-output-escaping="yes"/>
                    </content:encoded>
                </item>
            </xsl:if>
        </xsl:template>

    </xsl:stylesheet>

  • Warren Buckley 2087 posts 4568 karma points MVP 6x admin hq c-trib
    Sep 05, 2011 @ 12:17
    Warren Buckley
    0

    Hi Stephen,
    I would check your xPath selector.

    <xsl:apply-templates select="$homeNode//doNews/* [@isDoc]">

    This selector is saying any node no matter how deep under the homeNode variable (which should be your homeNode of your site) find all nodes/pages that have are doNews document type or a propertyAlias, then find any child beneath doNews that is a document.

    I would recommend you try this first to be more specific, by saying find the document type doNews as a child of the homeNode and then find me any nodes underneath that.

    <xsl:apply-templates select="$homeNode/doNews[@isDoc]/* [@isDoc]">

    or try being specific and select the news item document type underneath doNews.

    <xsl:apply-templates select="$homeNode/doNews[@isDoc]/newsItemDocumentType [@isDoc]">
  • Stephen 204 posts 246 karma points
    Sep 05, 2011 @ 12:42
    Stephen
    0

    Hi Warren,

    I've tried both methods with no change i begining to think it might be connected to my "$homeNode"

      <!-- Root Node -->
        <xsl:variable name="rootNode" select="$currentPage/ancestor-or-self::root" />

        <!-- Homepage -->
          <xsl:variable name="homeNode" select="$rootNode/doHome [@isDoc]" />

    Where my Site structure is

    Content

    ----home (doHome)

    --------news (doNews)

    ------------news item (doNewsItem)

     


  • Warren Buckley 2087 posts 4568 karma points MVP 6x admin hq c-trib
    Sep 05, 2011 @ 12:46
    Warren Buckley
    0

    A way for testing a variable is selecting the correct node is to do an copy-of.
    For example wrap a textarea around a copy-of and you will see the node/s it has selected.

    <textarea>
    <xsl:copy-of select="$homeNode" />
    </textarea> 

    You will be able to quickly tell if its selecting the right things or not.
    But you could try to have your xPath all in one and drop the homeNode variable it was designed to help selecting it quickly.

     

    <xsl:apply-templatesselect="$currentPage/ancestor-or-self::doHome/doNews[@isDoc]/doNewsItem [@isDoc]">

     

  • Stephen 204 posts 246 karma points
    Sep 05, 2011 @ 16:45
    Stephen
    0

    Still no joy using the xpath all in one, i'll try the copy-of method to see what nodes have been selected.

    Cheers,

    Stephen

Please Sign in or register to post replies

Write your reply to:

Draft