Copied to clipboard

Flag this post as spam?

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


  • Marie 3 posts 23 karma points
    Feb 02, 2016 @ 00:45
    Marie
    0

    formatAsDate renders current date rather than custom date

    Using Umbraco 7.2.8, I am struggling to render custom properties for sibling pages. I am new to razor and still learning.

    I have found a user-created solution for rendering a truncated version of the introduction (see below), but cannot get 'customDate' property to show properly when paired with 'formatAsDate:true'.

    Using the 'formatAsDate' causes the date to show the current date rather than my custom date. What am I doing wrong here?

    Partial below:

    @{ var siblings = @Model.Content.Siblings(); }

    @foreach (var post in siblings.Where(x => x.Id != Model.Content.Id)) {

                                <div class="date">@Umbraco.Field("@post.customDate", formatAsDate: true)</div>
    
    
                                <p>@post.GetProperty("Introduction").Value.ToString().Substring(0, 
                                        @post.GetProperty("Introduction").Value.ToString().Length < 240 ? 
                                            @post.GetProperty("Introduction").Value.ToString().Length : 240)...</p>
    
                            }
    
  • Marie 3 posts 23 karma points
    Feb 02, 2016 @ 03:34
    Marie
    0

    I've just figured out I can get the format that I want like this, but, is this correctly done?

    @(post.GetPropertyValue

Please Sign in or register to post replies

Write your reply to:

Draft