Copied to clipboard

Flag this post as spam?

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


  • Nicky Christensen 76 posts 166 karma points
    Nov 14, 2011 @ 10:36
    Nicky Christensen
    0

    Very simple razor question

    Hey guys...

    Im having problems listing some content under a folder....
    I have a template names Frontpage Box, and the alias of the template is FrontpageBox

    Im created a razor script file, and a macro for listing the items under the folder...
    However, I cant get it to list my items...

    The script is pretty simple:

    <ul>

        @foreach (var item in @Model.FrontpageBox.Where("Visible"))

        {

        <li>Dette er en test<a href="@item.Url">@item.Name</a></li>

    }

    </ul>

    I've tried @Model.FrontpageBoxes also, which doens't work... I've tried outputting something within the foreach, however, it never gets into the foreach... ? What am i doing wrong? 

  • Nicky Christensen 76 posts 166 karma points
    Nov 14, 2011 @ 10:50
    Nicky Christensen
    0

    By the way, the structure of the site is:

    Home

    Products

    Frontpage Boxes

    - Frontpage box1

    - Frontpage box2

    - Frontpage box3

     

  • UmbracoNewb 31 posts 53 karma points
    Nov 14, 2011 @ 12:53
    UmbracoNewb
    0

    Hey Nicky

    I guess you need to look at which nodes you want to look at. Currently you are only looking at the node you are currently at and nothing else.

    You could try:

    @foreach (var item in @Model.NodeById(1000).Children.FrontpageBox.Where("Visible"))

  • UmbracoNewb 31 posts 53 karma points
    Nov 14, 2011 @ 13:31
    UmbracoNewb
    0

    @{var nodeCollection Model.NodeById(Parameter.topNode).Descendants("FrontPageBoxes")}

    <ul>
    @foreach(var nodeItem in nodeCollection){
      <li>Dette er en test<a href="@nodeItem.Url">@NodeItem.Name</a></li>                                                                            
    }

    </ul>

    Til example uses a macro parameter (Parameter.topNode). Hope you can use it :)

Please Sign in or register to post replies

Write your reply to:

Draft