Copied to clipboard

Flag this post as spam?

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


  • Simon Bowler 14 posts 34 karma points
    Jun 27, 2012 @ 18:36
    Simon Bowler
    0

    Razor - Get HTML of child nodes

    Hi,

    I am new to Umbraco and Razor. I have built a some page slike this

    Records table
         Record item 1
         Record item 2
         Record item 3

    I have this razor script which sits in the 'Records table' template

    @foreach (var page in @Model.Children) {
          <a chref="@page.Url" >@page.Name</a>
     }

    That works, it lists out the sub pages of "Records table".

    What I want to do is pull out more info not just the page name. There is a div in each of these pages which I wish to display on the 'Records table' page. So something like @page.div.wrap

    Can anyone help?

    Thanks,

    Simon

     


     

     

     

  • Christian Bech 20 posts 51 karma points
    Jun 27, 2012 @ 20:44
    Christian Bech
    0

    Hi Simon.

    You can access all the generic properties on your document type. In stead of the @page.Name you could write @page.bodyText if you have a property bodyText added to your document type.

    It could look like this: 

     

    @foreach (var page in @Model.Children) {

          <div>@page.bodyText</div>

     }

    Hope that the above example is what you were looking for.

    /Christian

     

  • Simon Bowler 14 posts 34 karma points
    Jun 28, 2012 @ 13:12
    Simon Bowler
    0

    This worked great, thanks a lot Christian

  • 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