Copied to clipboard

Flag this post as spam?

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


  • N. Tuver 3 posts 23 karma points
    Apr 04, 2014 @ 13:08
    N. Tuver
    0

    Get child nodes displayed in master?

    I am currently making an one page website in Umbraco.

    I have build the pages/templates like this:

    Master
    Home
    Services
    etc.

    I want to show content from all children(home, services, etc.) on the frontpage (master).

    Untill now i have managed to get propertys from the child nodes like this, shown on the frontpage:

    <umbraco:Macro runat="server" language="cshtml">
    @foreach (var page in @Model.Children) {
    @page.Name
      }
    </umbraco:Macro>

    This shows me names of every child, on the frontpage.

    But how do i get all the html, and not only some propertys?

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Apr 04, 2014 @ 13:21
    Dennis Aaen
    0

    Hi N. Tuver,

    You can add the markup that you want. So if you want the name of the pages to be in a list you could do something like this:

    <umbraco:Macro runat="server" language="cshtml">
    <ul>
    @foreach (var page in Model.Children) {
          <li><a href="@page.Url">@page.Name</a></li>
     
      }
    </ul>
    </umbraco:Macro>

     

    So you shall build the HTML by your self. But Umbraco has some pre defined snippet e.g list pages from CurrentPage.  

    /Dennis

  • N. Tuver 3 posts 23 karma points
    Apr 04, 2014 @ 13:41
    N. Tuver
    0

    I already got all the html in each template.

    Richt now it's working like a normal website with a menu wich direct you to each child template.

    But, i want all content on one page instead. So to see each child template i just want to scroll down the frontpage. 

    Before implementing it to Umbraco i had just one html file. But to make it more usable i have split the code into sections, and each section in a template.

    For example:

    Master page:

    <body>

    <title>Title</title>

    <div>//Here i want content from my about page</div>

    <div>//Here i want content from my services page</div>

    </body>

     

    about page:

    <p>This is the about page</p>

     

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Apr 04, 2014 @ 14:06
    Dennis Aaen
    0

    Hi N. Tuver,

    Okay then I would recommend you to create a marco so you can place it on the master template, then it will go again on all pages.

    Here is the documentation how to create macros, so you can use the code on different pages. http://our.umbraco.org/documentation/reference/templating/macros/managing-macros

    Umbraco also comes with some pre define snippets. You can find the snippets when you create a new razor file. I would recommend to use Partial View Macro Files, the files that you can create under Scripting Files folder in the developer section uses the old razor.

    Since you´re new to Umbraco I also recommend you to go the Umbraco TV and see the free videos, there you will get the basic stuff about working with Umbraco.

    Hope this helps,

    /Dennis

  • N. Tuver 3 posts 23 karma points
    Apr 04, 2014 @ 14:32
    N. Tuver
    0

    That seems to work perfectly!

    Thank you for helping..

     

     

Please Sign in or register to post replies

Write your reply to:

Draft