Copied to clipboard

Flag this post as spam?

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


  • Morten 105 posts 345 karma points
    Mar 14, 2017 @ 14:45
    Morten
    0

    Inherit property value from parent node ("master")

    Hi! I have a master page. My master.cshtml page has my header, @RenderBody(), and my footer.

    My footer has some text, which I get from a Vorto property using @Model.Content.GetVortoValue("contactText").

    Now: This footer is used throughout the site and is never changed, which is why I put it in my master template page. However, when I go to a subpage (like /news/), the @Model has changed and no longer has the Vorto property values that the master template did.

    It does make sense why it doesn't have that. I guess you could call this unneeded and bad behavior (that all my child pages inherit some property from the footer), but I'm not sure what else I can do.

    Should I do something like a Partial View for my footer perhaps? What other options do I have?

    Thanks!

  • Alex Skrypnyk 6182 posts 24283 karma points MVP 8x admin c-trib
    Mar 14, 2017 @ 14:49
    Alex Skrypnyk
    100

    Hi Morten

    1. It will be nice to do Partial for the footer, then you will be able to use CachedPartial, that is much faster than render footer on each page with each request.
    2. Instead of using Current page model like @Model.Content.GetVortoValue("contactText"), try to use rootNode, like this:

      var rootNode = Umbraco.AssignedContentItem.Site(); rootNode.GetVortoValue("contactText");

    With this code you will use the same root node on all pages. Hope it will help you.

    Thanks,

    Alex

  • Morten 105 posts 345 karma points
    Mar 14, 2017 @ 14:53
    Morten
    0

    Hi Alex!

    That's very cool. It worked perfectly, thanks!

    How much faster is a CachedPartial? My footer has two pictures in it (SVGs though). What about a CachedPartial for the header as well? One image (same image as in footer). Are we talking crazy fast compared to or?

    Thanks!

  • Alex Skrypnyk 6182 posts 24283 karma points MVP 8x admin c-trib
    Mar 14, 2017 @ 14:55
    Alex Skrypnyk
    0

    Morten,

    CachedPartial will not affect images, it's a question of rendering, when it cached, this part of page renders from memory, and it takes 0,000001 seconds :)

    Thanks

  • Morten 105 posts 345 karma points
    Mar 14, 2017 @ 14:57
    Morten
    0

    Very cool! I'll definitely look into using this tomorrow. Thanks!

  • Alex Skrypnyk 6182 posts 24283 karma points MVP 8x admin c-trib
    Mar 14, 2017 @ 15:02
    Alex Skrypnyk
    0

    You are welcome, ask if you have some questions!

  • 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