Copied to clipboard

Flag this post as spam?

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


  • jigar 170 posts 233 karma points
    Jul 02, 2009 @ 09:52
    jigar
    0

    How to use Parent node property to pass dynamic value in macro?

    Hi All,

    Here I stuck at a problem. hope some one can help.

    Form this post i learnt how can we pass dinamica values to macro of user control. [ http://our.umbraco.org/wiki/reference/templates/umbracomacro-element ].

    here it is stated that you can pass your current executing node's Document Type defines a property macro by using syntax like [#YourNodePropertyName].

    now what i want is that i want to use the property of parent node.. lets say [#YourNode/ParentNode.PropertyName].

    in short i want to pass parent node's property dynamically to macro for user cotnrol.

    Please help me in this.

    Thanks In advance,

    Jigar

     

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Jul 02, 2009 @ 10:11
    Sebastiaan Janssen
    0

    Well, you could set:

    recursive="true"

    But then the property in "Yournode" would have to be empty and the same property in the parent needs to be filled.

    See the way "recursive" works is that it looks in the current node, if the property is empty, then it looks in the parent node, if the property is still empty it looks at the grandparent. This goes on until the highest node it can find.

    There might be a better solution out there that I am not aware of though. Personally, I would just use an XSLT macro to make this a bit more flexible.

  • Gerben 41 posts 136 karma points
    Jul 02, 2009 @ 10:14
    Gerben
    0

    I would advice you just pass the current executing node to the macro and find the id of the parent node in the user control by using this code.

     

     umbraco.cms.businesslogic.web.Document doc = new umbraco.cms.businesslogic.web.Document(ID of current node);      
    int ParentId = doc.Parent.Id;
  • jigar 170 posts 233 karma points
    Jul 02, 2009 @ 15:33
    jigar
    0

    Thanks guys,

    I think i am found better option.

    I am using [$MyPropertyNameOfParent] to do this. and i am getting this value in very specific way.

    Thanks for all helps.

    Regards,

    Jigar

     

Please Sign in or register to post replies

Write your reply to:

Draft