Copied to clipboard

Flag this post as spam?

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


  • Jason Rendel 10 posts 30 karma points
    Feb 21, 2013 @ 18:14
    Jason Rendel
    0

    "PostDate" in Blog 4 Umbraco

    Hello:

    I am working on a site that was built using the Blog 4 Umbraco package.  An issue has been raised related to the different dates displayed on the site.  In post lists a date shows such as 2/2/2013 and in the actual post the date will say 2/21/2013.  I looked into the post page template and the date is being displayed using this code:

    <span class="date"><umbraco:Item field="postDate" formatAsDate="true" runat="server"></umbraco:Item></span>

    Hoping to leverage the postDate in my listing macro as well I tried this:

    @using umbraco.cms.businesslogic.media
    
    @{  
        dynamic posts = Model.Descendants("BlogPostDocType").OrderBy("postDate descending");
        foreach(var post in posts){
            string outputDate = String.Format("{0:MMMM dd, yyyy}", post.postDate);
    
            <article>
                <span class="date">@outputDate</span>                         
            </article>
        }
    }

    However this code throws an error saying the postDate field cannot be found.  Is there a way to use this post date in the listings as well?  

  • Sahan Rodrigo 25 posts 97 karma points
    Feb 22, 2013 @ 11:10
    Sahan Rodrigo
    0

    Hi Jeason,

    Looking at the source code of the Blog 4 Umbraco package the "PostDate" is taken from the created date of the blog post (createDate), so you could use below code instead of your item field. There may be something wrong in the date formatting functionality to get and display the complete date. 

    <spanclass="date"><umbraco:Itemfield="createDate"formatAsDate="true"runat="server"></umbraco:Item></span>

    Try this for your macro as well.

    Hope this helps,

    Sahan

Please Sign in or register to post replies

Write your reply to:

Draft