Not sure if this is possible or not but I have a macro and for one of the parameters I would like to provide an XPath query that walks up the tree finding the closest node with a specific document property if the current node does not have one, and then pass that document property in as the parameter.
You can use recursive Macro Properties for this. Normally you pass a parameter using [#documentProperty].This will only look in the current document. When you want to do a recursive lookup of the value, you can use [$documentProperty].
Thanks for the feedback. I ended up changing my plan like 100 times it felt like. new to xsl & umbraco and it's... fun in a crazy sort of way. I was able to get my page working with what you provided, but i ended up changing it b/c of needed to do something else.
XPath Macro Parameter
Not sure if this is possible or not but I have a macro and for one of the parameters I would like to provide an XPath query that walks up the tree finding the closest node with a specific document property if the current node does not have one, and then pass that document property in as the parameter.
As an example:
Hi Simon,
You can use recursive Macro Properties for this. Normally you pass a parameter using [#documentProperty].This will only look in the current document. When you want to do a recursive lookup of the value, you can use [$documentProperty].
This WIKI explains the parameter syntax in detail.
Cheers,
Richard
That's great Ricahrd thanks, it solved my problem. It is also worth mentioning that it was your "Meta tags, Umbraco:item control and runat="server" magic" blog post that led me to the solution.
I'm looking at trying to do something similiar and I'm not having success.
i originally had my xpath query hardcoded in my xslt file and I'm extracting it in order to pass it through my macro. here's what i have.
<umbraco:Macro Alias="PostListMacro" runat="server" sourcePath="[$currentPage/Posts/Year/Month/*]"></umbraco:Macro>
macro param: alias=sourcePath name=sourcePath type=text
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet...>
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:template match="/">
<ul>
<xsl:for-each select="/macro/sourcePath">
more code
</xsl:for-each>
</ul>
</xsl:template>
</xsl:stylesheet>
did i set this up properly?
thanks for any help
You don't need a parameter if you are going to use $currentPage because you can do that directly in your macro.
E.g.
That said, if you are passing in a node as the source path you want the parameter type to perhaps be a content picker and then use:
<xsl:variable name="source" select="/macro/sourcePath" />
Thanks for the feedback. I ended up changing my plan like 100 times it felt like. new to xsl & umbraco and it's... fun in a crazy sort of way. I was able to get my page working with what you provided, but i ended up changing it b/c of needed to do something else.
thanks again!
is working on a reply...