Copied to clipboard

Flag this post as spam?

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


  • Tom 119 posts 447 karma points
    Dec 12, 2016 @ 13:20
    Tom
    0

    Route to other node when certain doctype is hit

    Hi, Is it possible to change the routing when I go to a page of a certain document type?

    How would I do that?

    Edit* Or is it possible to change which node is the current model in my _layoyt.cshml file?

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Dec 12, 2016 @ 23:58
    Alex Skrypnyk
    100

    Hi Tom

    You can use Custom controllers (Hijacking Umbraco Routes) - https://our.umbraco.org/documentation/reference/routing/custom-controllers.

    You can add any logic you want to any doctype, before razor rendering.

    Thanks,

    Alex

  • Tom 119 posts 447 karma points
    Dec 13, 2016 @ 08:11
    Tom
    1

    Thanks Alex! That seems to be it!

    But when make another rendermodel in my new controller and return it with CurrentTemplate(_newModel) it still uses the wrong template. How do I get it to use the template the new model needs?

  • Tom 119 posts 447 karma points
    Dec 13, 2016 @ 08:36
    Tom
    1

    Got it to work by changing the action thats called:

    ControllerContext.RouteData.Values["action"] = _model.Content.GetTemplateAlias();
    

    Thanks again, Alex!

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Dec 13, 2016 @ 10:06
    Alex Skrypnyk
    0

    Tom, you are welcome.

    Glad to help.

    Have a nice day!

    /Alex

Please Sign in or register to post replies

Write your reply to:

Draft