How do I get the node id of the page that called the RenderTemplate function from within the template being rendered? Using Model.Id in Razor (understandably) gives me the Id of the node that is being rendered not the one that called RenderTemplate.
The underlying code that the RenderTemplate control uses does not have any context of the page that references it. RenderTemplate executes the page/template as its own "thing". At present, the only way I could see how to pass in a reference via the querystring or other Request object collection (e.g. cookie, HttpItem, etc).
I have come across this same issue in the past, couldn't think of an elegant solution at the time ... will give it some thought. :-)
That all makes complete sense, I wondered if that might be the case. The concept of RenderTemplate is an excellent one, and if the calling page id was accessable then it would be just about perfect. I'm very impressed with all that uComponents offers and am often finding new ways of using them, keep up the good work.
I'll revisit this idea of the calling id later when I have some time to experiment and see if I can come up with any ideas.
We noticed that the topic ‘RenderTemplate, Razor &
calling page node id’ you created in the
Umbraco Community Forum does not have a post marked as a solution.
RenderTemplate, Razor & calling page node id
How do I get the node id of the page that called the RenderTemplate function from within the template being rendered? Using Model.Id in Razor (understandably) gives me the Id of the node that is being rendered not the one that called RenderTemplate.
Hi Matthew,
The underlying code that the RenderTemplate control uses does not have any context of the page that references it. RenderTemplate executes the page/template as its own "thing". At present, the only way I could see how to pass in a reference via the querystring or other Request object collection (e.g. cookie, HttpItem, etc).
I have come across this same issue in the past, couldn't think of an elegant solution at the time ... will give it some thought. :-)
Cheers, Lee.
Thanks Lee,
That all makes complete sense, I wondered if that might be the case. The concept of RenderTemplate is an excellent one, and if the calling page id was accessable then it would be just about perfect. I'm very impressed with all that uComponents offers and am often finding new ways of using them, keep up the good work.
I'll revisit this idea of the calling id later when I have some time to experiment and see if I can come up with any ideas.
Thanks again, Matt
I've been nagged by the Our Umbraco [[email protected]]:
So here is the answer: Lee has updated uComponents to handle this: http://ucomponents.codeplex.com/workitem/14607
is working on a reply...