Copied to clipboard

Flag this post as spam?

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


  • Steve Smith 75 posts 158 karma points
    Sep 11, 2018 @ 13:32
    Steve Smith
    0

    How to extend an Umbraco page to accept additional routing

    Hello,

    Supposing I have an Umbraco page:

    www.mysite.com/search/

    Is there some way I can extend the routing so that it handles further parameters, which are passed in to the model by the controller? (like a custom route).

    E.g. www.mysite.com/search/parameter-1/parameter/2

    Basically, I'd want the Umbraco doctype/template for "search" to handle that request, but for "parameter-1" and "parameter-2" to be passed in to the model.

    Hopefully I've explained what I'm trying to do :-) Is there some way Umbraco supports scenarios like this?

    Thanks,

    Steve.

  • Nik 1625 posts 7295 karma points MVP 7x c-trib
    Sep 11, 2018 @ 13:42
    Nik
    0

    Hi Steve,

    Have a look at this package: https://our.umbraco.com/packages/website-utilities/autoroutetemplate/

    I think that this should help you achieve what you are after :-)

    Cheers

    Nik

  • Steve Smith 75 posts 158 karma points
    Sep 11, 2018 @ 13:45
    Steve Smith
    0

    Thank you. Was hoping there might be a way to have some kind of hybrid between a standard Umbraco doc type and a custom route "out of the box" - but I'll certainly take a look at that package.

  • James Meredith 18 posts 91 karma points
    Sep 12, 2018 @ 08:50
    James Meredith
    0

    Could you not just use query string parameters to do this www.mysite.com/search/?p1=parameter-1&p2=parameter-2 and then use a RenderMvcController to pass information into a custom model

  • Steve Smith 75 posts 158 karma points
    Sep 12, 2018 @ 18:52
    Steve Smith
    0

    Thanks, yes, for that particular page it would be possible to do that.

    However, I have some other pages where from a friendly Url point of view, it would be nicer to have the parameters as "folders". E.g. I have to output some products.

    Rather than:

    /products/?id=1234&name=acme

    It would be nicer to have:

    /products/1234/acme/

    The package linked to in the other reply would probably work fine. Just feel there should be a way of doing it "out the box" too though :)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies