Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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>
<td style="color:black;font-size:15px;font-weight:bold">
Start:
@childPage.startDateTime
End:
@childPage.endDateTime
<td colspan="2">
@childPage.eventShortDesc
<tr height="50px"/>
}
</table>
I've actually just figured this out, I had my date test in the wrong place!
Now reads:-
@if (Model.Children.Where("Visible").Any())
@foreach (var childPage in Model.Children.Where("Visible && startDateTime >= @0", DateTime.Now))
is working on a reply...
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.
Continue discussion
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>
}
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>
}
is working on a reply...
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.