Thank you - but I need it to be dynamic as I do not know what the path will be as this will be entered by the user. As such it may be descendants, ancestors, etc. It is for this reason that I was looking at XPath.
I don't know if it'll work in this context, but you could try using the $currentPage token in your XPath? That should grab the current node, but I don't know if it works in the Umbraco helper.
XPath In Razor Macro
Hello All,
I am trying to retrieve the relevant node in a macro with the method:
The idea is that a get the node relevant to the CurrentPage - so for example:
However this does not seem to be working - can anybody help please?
Regards, L
Anybody who can help it would be warmly appreciated as I am desperate.
Regards, L
You could do this in pure Razor, no need for XPath. Try:
That should give you the page you're after, relative to the current page.
Hi Tim,
Thank you - but I need it to be dynamic as I do not know what the path will be as this will be entered by the user. As such it may be descendants, ancestors, etc. It is for this reason that I was looking at XPath.
Regards, L
I don't know if it'll work in this context, but you could try using the $currentPage token in your XPath? That should grab the current node, but I don't know if it works in the Umbraco helper.
Hi Tim,
Thanks - but $currentPage does not work in Razor script. I have access to the CurrentPage but not sure how I could use this.
I know it must be possible as Umbraco Forms uses the current node as Current Page when specifying an XPath.
Hope someone can maybe add to this??
Regards, L
is working on a reply...