I have a C# usercontrol which I call through a macro in my template. The macro invocation requires a NodeID to be passed where in some cases the ID is a property of another node.
The above declaration for NodeID is off-course wrong, but what I would like to know is whether there is a syntax that actually accomplishes what I want. If possible without the help of XSLT.
If the node id is a property of the page that the macro is on, then yes. Assuming you have a page that has a property that contains a nodeId, say "myNode" then the syntax would be something like:
I am aware of the [#property] syntax but in this particular case the node from which I would like to access a 'child' property is not the current page. The recursiion support in Umbraco doesn't help here either because as I understood recursion is always upwards in the tree.
If recursion would work downwards then conceptually it still is not correct imho (and so is recursion upwards).I have this well-defined node of which the property that I would like to use is logically a child property. Why would I have to iterate the umbraco tree (who knows how many nodes are in there) when I clearly know where the property is located? If you look at it from a programming point of view it is against everything we have learned before and considered as being good programming behavior.
Anyhow, if this is how it is then I will have to make a work-around.
Sorry for not getting back to you sooner, I've been away on holiday!
If you know the node, I suppose you could use a node picker to pass the node ID through and then pull the property out in your user control/macro. If you wanted to make it more dynamic, you could pass in the node id as one property and the property alias as another and then get the property out in your macro maybe?
Pass a property of a node as macro parameter
Hi,
I have a C# usercontrol which I call through a macro in my template. The macro invocation requires a NodeID to be passed where in some cases the ID is a property of another node.
So, sometimes the macro is as simple as:
But when the ID is a property of another node I don't know how to pass that. It ideally should be something like the following:
The above declaration for NodeID is off-course wrong, but what I would like to know is whether there is a syntax that actually accomplishes what I want. If possible without the help of XSLT.
Any help is highly appreciated.
Jos
If the node id is a property of the page that the macro is on, then yes. Assuming you have a page that has a property that contains a nodeId, say "myNode" then the syntax would be something like:
[#myNode]
You can also pass in recursive values, see the wiki article here: http://our.umbraco.org/wiki/reference/templates/umbracomacro-element/macro-parameters/advanced-macro-parameter-syntax
Hope that helps!
:)
Tim,
Thanks for the response.
I am aware of the [#property] syntax but in this particular case the node from which I would like to access a 'child' property is not the current page. The recursiion support in Umbraco doesn't help here either because as I understood recursion is always upwards in the tree.
If recursion would work downwards then conceptually it still is not correct imho (and so is recursion upwards).I have this well-defined node of which the property that I would like to use is logically a child property. Why would I have to iterate the umbraco tree (who knows how many nodes are in there) when I clearly know where the property is located? If you look at it from a programming point of view it is against everything we have learned before and considered as being good programming behavior.
Anyhow, if this is how it is then I will have to make a work-around.
Jos
Hi Jos,
Sorry for not getting back to you sooner, I've been away on holiday!
If you know the node, I suppose you could use a node picker to pass the node ID through and then pull the property out in your user control/macro. If you wanted to make it more dynamic, you could pass in the node id as one property and the property alias as another and then get the property out in your macro maybe?
is working on a reply...