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?
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.
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
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 :)
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.
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
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.
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
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 :)
is working on a reply...