Copied to clipboard

Flag this post as spam?

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


  • Rajeev 126 posts 154 karma points
    Jul 15, 2011 @ 09:54
    Rajeev
    0

    Dynamic Node Issue checking with Date Property?

    I have a Node with Property startDate and endDate and have its template
    I need to display the item in the template only if that is within the date range.
    Otherwise that shouldn't be shown in the page.@Model will give the dynamic node, I would like to know how to check the date range for this, I have tried the .Where and
    @Model.startDate >=DateTime.Now.Date etc and I am getting an error like DynamicNull cannot use >= with DateTime.Date

    Please let me know.

    Note:
    Will update if that is @Model.startDate property returning a string and I need to typecast it.

    Thanks,
    Rajeev

  • Rajeev 126 posts 154 karma points
    Jul 15, 2011 @ 10:14
    Rajeev
    0

    I have checked first if the node is null and if that is within the range. 

    if ( (Model!=null) && Model.startDate<=DateTime.Now.Date) and it worked.

    Note: Here startDate was a mandatory field, else you have to validate that as well.

    Thanks,

    Rajeev

     

     

     

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Jul 15, 2011 @ 10:51
    Sebastiaan Janssen
    0

    In 4.7.1 you don't have to do all of those elaborate checks any more, you can just go:

    var currentEvents = person.Descendants("Event").Where("dateStart >= DateTime.Today").OrderBy("dateStart");
    
                foreach (var eventItem in currentEvents)
                {
                    @RenderEventList(eventItem)
                }
    
  • Rajeev 126 posts 154 karma points
    Jul 18, 2011 @ 08:13
    Rajeev
    0

    Thank you.That is great.

    When can we expect the stable version of this.?

    -Rajeev

     

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Jul 18, 2011 @ 08:27
    Sebastiaan Janssen
    0

    The beta is going to be released by the end of the month. But you can download a nightly and just use the umbraco.macroengine.dll from it to upgrade the Razor engine. It has been very stable from what I've seen so far.

  • Rajeev 126 posts 154 karma points
    Jul 19, 2011 @ 03:47
    Rajeev
    0

    Thank you for the update Sebastian.

    -Rajeev

Please Sign in or register to post replies

Write your reply to:

Draft