Copied to clipboard

Flag this post as spam?

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


  • Owain Williams 432 posts 1288 karma points MVP 3x c-trib
    Jul 05, 2015 @ 17:59
    Owain Williams
    0

    Access document type date that belongs to another page?

    Hi, Is it possible to access the values that are stored in another page?

    i.e. On my homepage document type I have a 'Social' tab, in here I have my social media usernames which are used by a plugin on the homepage. I then have another document type, general page, but I would like to access the information that is stored within the homepage document type for the social tab. I don't want to have to enter my details in everytime.

    Cheers,

  • Dennis Aaen 4457 posts 17970 karma points admin hq c-trib
    Jul 05, 2015 @ 18:14
    Dennis Aaen
    100

    Hi Owain,

    Depending on how you are querying the field in your template you can make this field recursive. Which means will go up though the ancestors until it´s find the field on the page, and it has a value. Try to see this documentation.

    Especially rendering a field with UmbracoHelper

    https://our.umbraco.org/documentation/Reference/Templating/Mvc/views

    Let´s say that you have a field called bodyContent, the the syntax would be like this

    @Umbraco.Field("bodyContent", recursive: true)
    

    If you are in a partial view or partial view macro you can do something like this:

    @{       
       if (CurrentPage.HasValue("bodyContent", true)){
           <p>@CurrentPage.bodyContent</p>
       }           
    }
    

    Hope this helps,

    /Dennis

  • Owain Williams 432 posts 1288 karma points MVP 3x c-trib
    Jul 06, 2015 @ 12:09
    Owain Williams
    0

    Thanks! That's perfect!

  • 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