Copied to clipboard

Flag this post as spam?

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


  • Michael Beever 74 posts 155 karma points
    Apr 28, 2020 @ 14:36
    Michael Beever
    0

    Content from another page

    Hello,

    I quite new to Umbraco and currently creating a few sites. To improve how it looks I have had to created top pages to allow for my pages to be sub pages

    IE

    Site One

    Home Page

    Content Pages

    Site Two

    Home Page

    Content Page

    Originally both Home pages were on the top level but found it complicated matters. I have on site One footer information i want to use across all of the pages. When the home page was on the top level i was using this code.

    "var home = (HomePage)Model.Content.Site()"

    Now I have moved it a level down I am unable to get anything to work. Is this possible?

    Any advice appreciated but as I said I am new to this.

    Thanks

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Apr 28, 2020 @ 16:38
    Alex Skrypnyk
    0

    Hi Michael,

    Use this code:

    var home = Model.Content.Site().Children.OfType<HomePage>().FirstOrDefault();
    

    Check out available Umbraco Helper methods here in docs - https://our.umbraco.com/documentation/reference/querying/umbracohelper/

    Thanks,

    Alex

  • Michael Beever 74 posts 155 karma points
    Apr 29, 2020 @ 12:52
    Michael Beever
    0

    Didn't work :(

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Apr 29, 2020 @ 14:02
    Alex Skrypnyk
    0

    What error? Can you share?

  • Michael Beever 74 posts 155 karma points
    Apr 30, 2020 @ 06:39
    Michael Beever
    0

    Hi Alex, this is where I have issues. Normally I see the error on the page error log. The admins of the version I am using does not want to turn them on.

    Is there any other way to find logs?

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Apr 29, 2020 @ 19:49
    Alex Skrypnyk
    0

    maybe this:

    var home = Model.Content.Site().Children.FirstOrDefault();
    
  • Michael Beever 74 posts 155 karma points
    Apr 30, 2020 @ 07:39
    Michael Beever
    0

    I suppose the question I should be asking is.

    What is the best way to create a Footer content ie Contact Details social media and opening hours.

    Rather than doing this on every page I just want to do it once. How is this possible? I was using the example from the starter site but seems a bit limited.

    Thanks

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Apr 30, 2020 @ 14:59
    Alex Skrypnyk
    0

    I think the best way is to add these properties to the root node, it's super easy to extract root node properties from any page on the site.

    Umbraco Helper has Root() method for retrieving the data from the root node. In Umbraco 7 exactly the same method called Site() it returns root IPublishedContent item.

    Thanks,

    Alex

Please Sign in or register to post replies

Write your reply to:

Draft