Is it possible to pass a macro the value of an umbraco:item from a template?
Currently in my templates I have:
<!-- determine the body class based on the selected scheme, or parent node scheme--> <body class="<umbraco:Item field="colorScheme" useIfEmpty="default" recursive="true" runat="server"></umbraco:Item>">
This is working nicely, and provides the end result that I need. However, I also have a macro:
Rather than having the macro depend on the parameter [#randomImage] which is a media Node, I'd rather allow it to default to the parent recursively, much like the body class does above.
Using page parameters Recursively for a macro
Is it possible to pass a macro the value of an umbraco:item from a template?
Currently in my templates I have:
This is working nicely, and provides the end result that I need. However, I also have a macro:
Rather than having the macro depend on the parameter [#randomImage] which is a media Node, I'd rather allow it to default to the parent recursively, much like the body class does above.
I tried the following:
Which results in the following output:
Returning the NodeId of the parent as expected, but the macro doesn't appear to run?
Can this even be done this way, or is there a correct approach?
You can create the macro in code-behind and set properties from there.
Explained in the following topic/post: http://our.umbraco.org/forum/developers/api-questions/5407-Macro-parameters-from-codebehind?p=0#comment19960
Hi Dave,
you just need to know a little more about the bracket syntax (like [#randomImage]). See this page: http://our.umbraco.org/wiki/reference/templates/umbracomacro-element
which will tell you to do this:
Basically "$" instead of # in the bracket syntax makes the page variable recursive
/Josh
Josh,
Thanks! that's exactly what I needed.
~Cheers
is working on a reply...