Hi , I am using Cultiv Razor
Examples which is an excellent example for practicing razor , just need to know if i want to push the events on homepage how will i acheive this, the razor code provided only shows the subnodes of the parent node ,what if i want to show the subnodes of a particular page on home page . for instance i want to show latest 3 events by date on homepage ,
@foreach (var group in Model.Children.OrderBy("EventDateTime [desc]").Next(3)) { <div class="column-holder"> @foreach (var item in group) { <div class="cell"> <h3>@item.Name</h3> <em>@String.Format("{0:dddd, MMMM d yyyy}", item.EventDateTime) - Starts at @String.Format("{0:HH:mm}", item.EventDateTime)</em><br /> <span>@(Library.Truncate(Library.StripHtml(item.EventDescription), 200, true))</span> </div> <p class="readmore-link"><a href="@item.Url" class="link more">read more</a></p> } </div> }
The above doesnt works, as I have used Model which is the current page which is a homepage having no subnodes.
Cultiv Razor Examples
Hi , I am using Cultiv Razor Examples which is an excellent example for practicing razor , just need to know if i want to push the events on homepage how will i acheive this, the razor code provided only shows the subnodes of the parent node ,what if i want to show the subnodes of a particular page on home page . for instance i want to show latest 3 events by date on homepage ,
@foreach (var group in Model.Children.OrderBy("EventDateTime [desc]").Next(3))
{
<div class="column-holder">
@foreach (var item in group)
{
<div class="cell">
<h3>@item.Name</h3>
<em>@String.Format("{0:dddd, MMMM d yyyy}", item.EventDateTime) - Starts at @String.Format("{0:HH:mm}", item.EventDateTime)</em><br />
<span>@(Library.Truncate(Library.StripHtml(item.EventDescription), 200, true))</span>
</div>
<p class="readmore-link"><a href="@item.Url" class="link more">read more</a></p>
}
</div>
}
The above doesnt works, as I have used Model which is the current page which is a homepage having no subnodes.
Any suggestions or help will be appreciated.
@foreach (var group in Model.Children.Where("NodeTypeAlias = \"Events\"").OrderBy("EventDateTime").InGroupsOf(1))
I tried the above syntax with no success.
@foreach (var group in Model.NodeById(1121).Descendants().OrderBy("EventDateTime").InGroupsOf(1))
well this one works but it shows all the events and is there any more elegant way of doing it , here i am using node of event which is 1121
is working on a reply...