Copied to clipboard

Flag this post as spam?

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


  • Mr A 216 posts 278 karma points
    Oct 05, 2011 @ 16:51
    Mr A
    0

    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.EventDateTimeStarts at @String.Format("{0:HH:mm}"item.EventDateTime)</em><br />
                <span>@(Library.Truncate(Library.StripHtml(item.EventDescription)200true))</span>
            </div>
            <class="readmore-link"><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.

  • Mr A 216 posts 278 karma points
    Oct 05, 2011 @ 17:10
    Mr A
    0

    @foreach (var group in Model.Children.Where("NodeTypeAlias = \"Events\"").OrderBy("EventDateTime").InGroupsOf(1))

    I tried the above syntax with no success.

  • Mr A 216 posts 278 karma points
    Oct 05, 2011 @ 17:25
    Mr A
    0

    @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

  • 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