Copied to clipboard

Flag this post as spam?

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


  • Zubair Hasan 18 posts 88 karma points notactivated
    Nov 15, 2018 @ 17:20
    Zubair Hasan
    0

    I'm new to umbraco. I have different pages under Master page e.g. Books, chapter, Home. Chapters is the child page of books.

    I want to call books document different properties like bookname, authorname including chapter document description property on my home page.

    I need help.

  • Bharani Dharan Jayasuri 12 posts 126 karma points c-trib
    Nov 16, 2018 @ 09:19
    Bharani Dharan Jayasuri
    0

    Hi Zubair,

    If your site is structured in a way that Masterpage is your home page and Books is a direct child under it with document type alias, say for example called "books", and chapters with document type alias "chapters", you could write something like,

    @{
    var books = Model.Content.Site().Children("books").Where(x => x.IsVisible()).FirstOrDefault();
    var chapters = books.Children("chapters").Where(x => x.IsVisible()).ToArray();
    }
    
    @*Get properties from books*@
    <p>@books.GetPropertyValue("alias")</p>
    @*In the get properties from chapters*@
    <ul>
        @foreach(var item in chapters ){
            <li>
                <a href="@item.GetPropertyValue("alias")">@item.Name</a>
            </li>
        }
    </ul>
    
Please Sign in or register to post replies

Write your reply to:

Draft