Copied to clipboard

Flag this post as spam?

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


  • Joshua Foulk 1 post 21 karma points
    Dec 13, 2013 @ 06:47
    Joshua Foulk
    0

    Best practices to reduce property redundancy

    I just started using Umbraco a couple of days ago and at least one of those days was simply getting it running correctly on Azure (and playing with v6 vs. v7).

    I've settled on v7 and I'm using Mvc with Razor syntax.

    Now, I'm probably missing something very simple here, but it seems to me like the Document Type/Template structure is a bit redundant when it comes to filling out property information (when it comes to actually filling out content).

    If I have a simple site like this:

    Home

    -> About

    -> Contact Us

    There's some content that I only want to place once (like a banner image, or footer text) that is repeated across all pages.  What is the proper way to lay out the doc types and templates so that "Home" is the only place where those fields are populated.

    The only solution I've found is to use the Parent/Child relationships between About and Home and get the parent node when I'm on About, and then GetProperty("whatever").Value...  This works for something like footer text, but I don't want to have to do that every single time I need to get a property that is defined on the document type for the home page.  Is there a better way?

  • Chris Randle 67 posts 181 karma points c-trib
    Dec 16, 2013 @ 19:38
    Chris Randle
    0

    Hi there,

    It does not matter if you use 6 or 7 with this problem. Please try the following code - replacing 1000 and "aliasOfProperty" with the relevant values):

    var result  = new DynamicNode(1000).GetPropertyValue("aliasOfProperty", true);
  • Charles Afford 1163 posts 1709 karma points
    Dec 17, 2013 @ 22:22
    Charles Afford
    0

    Hi what you are asking for is doc type inheritence.

     

    In your doc type properties they get inherited from the top down

    (doctype) Home > (doctype) About Us

    Anything defined on Home will get  inherited by About Us

    Make sense?

    Charlie :)

  • Amir Khan 1282 posts 2739 karma points
    Dec 17, 2013 @ 22:40
    Amir Khan
    0

    For things like banner images you can use recursive properties so Umbraco will look up the tree to the nearest parent node with the property filled out if one hasn't been selected on that node. That way you can have a benner for the site, override it for a section if you want, and override it for an actual node.

Please Sign in or register to post replies

Write your reply to:

Draft