Copied to clipboard

Flag this post as spam?

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


  • Natasha 79 posts 195 karma points
    Dec 13, 2012 @ 13:15
    Natasha
    0

    FormatDateTime returning nothing

    Hi All

    I have been searching the forum for two days on this issue please can someone help?  I have a field in my news document type called Article Date alias 'articleDate'  I have written an xslt using formatdatetime but it returns nothing. The xslt is below and this is a link to the page that I used the macro in.  I've tried a few variations i.e. taken current page out etc.  Oh yes I'm using version 4.11

    <?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:umbraco.library="urn:umbraco.library" exclude-result-prefixes="umbraco.library">
      <xsl:output method="xml" omit-xml-declaration="yes"/>
      <xsl:param name="currentPage"/>
       
      <xsl:template match="/">

    <!-- The fun starts here -->
    <ul>
    <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">
       <xsl:if test="position() &lt;= 4">
      <li class="news">
        <h2><a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName"/>
            </a> | <xsl:value-of select="umbraco.library:FormatDateTime($currentPage/data [@alias='articleDate'], 'dd.MM.yy')"/>
       
    </h2>
               <xsl:variable name="firstParagraph" select="umbraco.library:StripHtml(substring-before(bodyText, '&lt;/p'))"/>
                               
          <p><xsl:value-of select="$firstParagraph"/></p>
      </li>
       </xsl:if>
    </xsl:for-each>
    </ul>

    </xsl:template>

    </xsl:stylesheet>

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Dec 13, 2012 @ 13:19
    Chriztian Steinmeier
    0

    Hi Natasha,

    The call is using the "Legacy Schema" syntax, which can, unfortunately be hard to detect if you're new to Umbraco.

    The highlighted line should look like this instead:

    <xsl:value-of select="umbraco.library:FormatDateTime($currentPage/articleDate, 'dd.MM.yy')" />

    Hope that helps - and don't hesitate to ask here - there are lots of friendly people who have had the same problems :-)

    /Chriztian 

  • Natasha 79 posts 195 karma points
    Dec 13, 2012 @ 14:21
    Natasha
    0

    Hi Chriztian

    Thanks so much for your speady reply.  I have replaced the code with the above but it's still retuning a blank.  Is there a stage I've missed out or something?  I also forgot to include the url in the post http://upgrade.c4eo.org.uk/news.aspx

    Thanks again

     

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Dec 13, 2012 @ 15:30
    Chriztian Steinmeier
    1

    Hi Natasha,

    I glanced too quick - you're inside a for-each, so you actually just need to say articleDate and nothing else:

    <xsl:value-of select="umbraco.library:FormatDateTime(articleDate, 'dd.MM.yy')"/>

    - you want the date of the current item in the iteration, not the $currentPage's articleDate every time ...

    /Chriztian

  • Natasha 79 posts 195 karma points
    Dec 13, 2012 @ 17:55
    Natasha
    0

    Thank you so much you're a superstar

  • 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