Copied to clipboard

Flag this post as spam?

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


  • Andrew Blackmore 84 posts 127 karma points
    Feb 10, 2010 @ 21:59
    Andrew Blackmore
    0

    Adding Date to Page Title

    I believe this is very simple, but for some reason, I'm not getting this to work. I am making a template for a blog within Umbraco and I am using the following code for my title

     

           <title>
    <umbraco:Item Field="pageName" runat="server" insertTextAfter=" - "></umbraco:Item>
    <umbraco:Item Field="blogName" recursive="true" runat="server" insertTextAfter=" - "></umbraco:Item>
    <xsl:value-of select="umbraco.library:FormatDateTime($currentPage/@createDate, 'MMM d, yyyy')"/>
    </title>

    The first two lines work perfectly. The third line does not. I followed the example in the API Cheatsheet and only changed how the date should be formatted and that I wanted to use createDate instead of updateDate.

     

    A little bit confused here. New to Umbraco and XSLT so hopefully is a simple misunderstanding.

     

    Thanks.

  • Chris Koiak 700 posts 2626 karma points
    Feb 10, 2010 @ 22:07
    Chris Koiak
    4

    Hi Andrew,

    You cannot have xslt directly on a template. A template is a standard .NET masterpage and can only have ;NET controls. However you can use inline xslt on the Item control.

    The following line should work

    <umbraco:Item runat="server" field="createDate" xslt="umbraco.library:FormatDateTime({0}, 'MMM d, yyyy')" />

    Cheers,

    Chris

  • Andrew Blackmore 84 posts 127 karma points
    Feb 12, 2010 @ 15:28
    Andrew Blackmore
    0

    Thanks a lot Chris! That worked perfectly and also helped me understand how all this works a lot better. So if I have this straight -

     

    templates are .NET pages and the xslt is either contained like you have shown or used via macros?

  • Chris Koiak 700 posts 2626 karma points
    Feb 12, 2010 @ 18:57
    Chris Koiak
    0

    Yep, completely correct!

    (the only third option for xslt is to use http://our.umbraco.org/projects/xsltresult... but this really just extends the xslt ability of 'umbraco:item')

    Also, if you're a .NET developer you should notice that you can put standard .NET controls directly onto the template, rather than embedding it via a macro.

     

Please Sign in or register to post replies

Write your reply to:

Draft