Copied to clipboard

Flag this post as spam?

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


  • Vic Carter 2 posts 22 karma points
    Dec 20, 2012 @ 18:23
    Vic Carter
    0

    Cannot get pubDate to display using FormatDateTime()

    My Code:

    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>

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

    exclude-result-prefixes="msxml umbraco.library">

     

     

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

     

    <xsl:param name="currentPage"/>

     

    <xsl:variable name="numberOfItems">

    <xsl:choose>

    <xsl:when test="/macro/numberOfItems != ''">

    <xsl:value-of select="/macro/numberOfItems"/>

    </xsl:when>

    <xsl:otherwise>10</xsl:otherwise>

    </xsl:choose>

    </xsl:variable>

    <xsl:variable name="excerptLength">

    <xsl:choose>

    <xsl:when test="string(/macro/excerptLength) != ''">

    <xsl:value-of select="/macro/excerptLength"/>

    </xsl:when>

    <xsl:otherwise>0</xsl:otherwise>

    </xsl:choose>

    </xsl:variable>

     

    <xsl:variable name="feed" select="/macro/feedUrl"/>

    <!-- cache for 30 minutes (1.800 seconds) -->

    <xsl:variable name="cacheRate" select="number(1800)"/>

     

    <xsl:template match="/">

     

    <!-- start writing XSLT -->

    <xsl:choose>

    <xsl:when test="$feed != ''">

    <xsl:variable name="feedContent" select="umbraco.library:GetXmlDocumentByUrl($feed, number($cacheRate))"/>

    <xsl:choose>

    <xsl:when test="$feedContent != 'error'">

    <xsl:call-template name="renderFeed">

    <xsl:with-param name="feedContent" select="$feedContent"/>

    </xsl:call-template>

    </xsl:when>

    <xsl:otherwise>

    <p>

    <strong>Feed Viewer Macro Error: Error fetching feed</strong><br />

    The feed '<xsl:value-of select="$feed"/>' could not be loaded. Verify that the feed url exists and that you have an

    active internet connection

    </p>

    </xsl:otherwise>

    </xsl:choose>

    </xsl:when>

    <xsl:otherwise>

    <p>

    <strong>Feed Viewer Macro Error: No feed chosen</strong><br />

    Please make sure to add a value in the "Feed Url" parameter

    </p>

    </xsl:otherwise>

    </xsl:choose>

    </xsl:template>

     

    <xsl:template name="renderFeed">

    <xsl:param name="feedContent"/>

    <xsl:if test="count($feedContent//item) &gt; 0">

    <ul class="feedList">

    <xsl:for-each select="$feedContent//item">

    <xsl:if test="position() &lt;= $numberOfItems">

    <li>

    <b><xsl:value-of select="umbraco.library:FormatDateTime(pubDate,'d')"/></b><br />

    <xsl:choose>

    <xsl:when test="string($excerptLength) != '0'">

    <a href="{link}"><xsl:value-of select="umbraco.library:TruncateString(umbraco.library:StripHtml(title), number($excerptLength), '...')" disable-output-escaping="yes"/></a>

    </xsl:when>

    <xsl:otherwise>

    <a href="{link}"><xsl:value-of select="title" disable-output-escaping="yes"/></a>

    </xsl:otherwise>

    </xsl:choose>

    </li>

    </xsl:if>

    </xsl:for-each>

    </ul>

    </xsl:if>

    </xsl:template>

     

    </xsl:stylesheet>

     

    No matter how I try to format the date it always comes up blank in my list.  If I remove the umbraco function, the full pubDate is displayed as expected.  I grabbed the basic code from another umbraco user, is there something I am missing or is there an issue with the function?

    Any help would be greatly appreciated.

  • Vic Carter 2 posts 22 karma points
    Dec 20, 2012 @ 20:19
    Vic Carter
    0

    Got this working the way I wanted it to by changing this:

    <b><xsl:value-of select="umbraco.library:FormatDateTime(pubDate,'d')"/>

    to this:

    <b><xsl:value-of select="umbraco.library:FormatDateTime(substring(pubDate,1,16),'d')"/> 

     

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies