Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matt Bliss 176 posts 234 karma points c-trib
    Dec 28, 2011 @ 15:03
    Matt Bliss
    0

    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.

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Dec 29, 2011 @ 00:59
    Lee Kelleher
    1

    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.

  • Matt Bliss 176 posts 234 karma points c-trib
    Dec 29, 2011 @ 08:52
    Matt Bliss
    0

    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

  • Matt Bliss 176 posts 234 karma points c-trib
    Sep 17, 2012 @ 19:41
    Matt Bliss
    0

    I've been nagged by the Our Umbraco [[email protected]]:

    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.

    So here is the answer: Lee has updated uComponents to handle this: http://ucomponents.codeplex.com/workitem/14607

Please Sign in or register to post replies

Write your reply to:

Draft