Copied to clipboard

Flag this post as spam?

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


  • Mark Evans 86 posts 116 karma points
    Aug 20, 2014 @ 16:51
    Mark Evans
    0

    getting children of a particular document alias type

    im trying to get the children of a certain document type to show sub navigation.

    ive tried various code samples i found online but none of them work for me.

    i start by checking for my document type and get the currentPage id but this doesnt seem to support currentPage.Children so how would i go about getting sub pages of this page id?

    i essentially want the children at 1 level under document type ("Division") that are set to visible so i can get the name/url/image associated with these pages.....

    if (@Model.Content.DocumentTypeAlias == "Division")
        {
            var currentPage = @Model.Content.Id;
           
            // how do i loop thru this node to get the child pages?
                   
        }

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    {

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

  • Barry Fogarty 493 posts 1129 karma points
    Aug 20, 2014 @ 16:58
    Barry Fogarty
    0

    Model.Content.Children inside the if should return all child nodes.

  • Mark Evans 86 posts 116 karma points
    Aug 20, 2014 @ 17:29
    Mark Evans
    0

    thanksd this works ok now, i was trying to overcomplicate things....

    how do i get he actual image url?

    i have

    <div><imgsrc="@child.GetPropertyValue("DivisionSliderImage")"/></div>

    but the code is just showing the id number in the img tag.....

     

     

     

  • Jeavon Leopold 3008 posts 13221 karma points MVP 7x admin c-trib
    Aug 20, 2014 @ 18:03
    Jeavon Leopold
    0

    Something similar to this

    @{
        if(child.HasValue("DivisionSliderImage")){
            var mediaItem = Umbraco.TypedMedia(child.GetPropertyValue("DivisionSliderImage")); 
            <img src="@mediaItem.Url" alt="@mediaItem.Name"/>    
        }   
    }
    
  • Jeavon Leopold 3008 posts 13221 karma points MVP 7x admin c-trib
    Aug 20, 2014 @ 18:03
    Jeavon Leopold
    0

    Edited above

  • Mark Evans 86 posts 116 karma points
    Aug 21, 2014 @ 11:38
    Mark Evans
    0

    thanks

  • 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