Copied to clipboard

Flag this post as spam?

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


  • osbit 2 posts 52 karma points
    Feb 28, 2014 @ 21:47
    osbit
    0

    Displaying future events

    Hi,

    My first post on here!

    I have an events calendar page with all of the events created as child nodes underneath in the content page.

    I'm trying to write a simple Razor macro to list just the events that are either on or after today, but seem to be going wrong.

     

    Here's what I have so far:-

    @inherits umbraco.MacroEngines.DynamicNodeContext

     

     

    @* Ensure that the Current Page has children, where the property umbracoNaviHide is not True *@

    @if (Model.Children.Where("Visible && startDateTime >= @0", DateTime.Now).Any())

    {

        <table id="eventtable" border ="0">            

            @* For each child page under the root node, where the property umbracoNaviHide is not True *@

            @foreach (var childPage in Model.Children.Where("Visible"))

            {

    <tr>

    <td colspan="2" style="color:black;font-size:20px;">

    Event Name:

    <a href="@childPage.Url">

    @childPage.NodeName

    </a>

    </td>

    </tr>

    <tr>

    <td style="color:black;font-size:15px;font-weight:bold">

    Start:

    @childPage.startDateTime

    </td>

    <td style="color:black;font-size:15px;font-weight:bold">

    End:

    @childPage.endDateTime

    </td>

    </tr>

     

    <tr>

    <td colspan="2">

    @childPage.eventShortDesc

    </td>

    </tr>

    <tr height="50px"/>

            }

        </table>

    }

    The first 'if' statement is where I'm trying to list just the pages that I'm interested in.
    Any help would be very much appreciated.
    Thanks
  • osbit 2 posts 52 karma points
    Feb 28, 2014 @ 22:20
    osbit
    100

    I've actually just figured this out, I had my date test in the wrong place!

     

    Now reads:-

     

    @inherits umbraco.MacroEngines.DynamicNodeContext

     

     

    @* Ensure that the Current Page has children, where the property umbracoNaviHide is not True *@

    @if (Model.Children.Where("Visible").Any())

    {

        <table id="eventtable" border ="0">            

            @* For each child page under the root node, where the property umbracoNaviHide is not True *@

            @foreach (var childPage in Model.Children.Where("Visible && startDateTime >= @0", DateTime.Now))

            {

    <tr>

    <td colspan="2" style="color:black;font-size:20px;">

    Event Name:

    <a href="@childPage.Url">

    @childPage.NodeName

    </a>

    </td>

    </tr>

     

    <tr>

    <td style="color:black;font-size:15px;font-weight:bold">

    Start:

    @childPage.startDateTime

    </td>

    <td style="color:black;font-size:15px;font-weight:bold">

    End:

    @childPage.endDateTime

    </td>

    </tr>

     

    <tr>

    <td colspan="2">

    @childPage.eventShortDesc

    </td>

    </tr>

    <tr height="50px"/>

            }

        </table>

    }

  • 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