What I'm trying to do is creating a template page called manage in Umbraco with two toggle options of type bool.
When the user selects a bool option inside the manage page, the user clicks save and the page should reload, however when the page reloads the current values of the bool should be retrieved to check if the user has toggled some values already.
When the user goes to another page, such as "Sales", the sales page should get the bool values from the manage page before the sales page has loaded.
I was using a Surface Controller to achieve this, but the link you sent looks good to.
What's the difference between Surface controllers vs hijackings, do you have an example of when I use you a surface controller or hijacking?
So looking at your situation I think you need a route hijack, this fires early in the page render, here you can check your property then render with appropriate template.
So coming back to webforms think of surface controllers and their related partials about like usercontrols. Where you need reusable components.
Hijacks are more page specific, so lets say you had blog page type and you want to list all comments for that blog page but the comments come from 3rd party system. So in this instance makes more sense to create a hijack of the route then for that page get its comments and add to the extended model for that page and pass it through.
Surface Controller
Hi all,
I've a question regarding using the surface controller.
I've followed this tutorial https://codeshare.co.uk/blog/how-to-create-a-contact-form-in-umbraco-using-mvc-and-c/ on how to use a surface controller.
However if would anyone know how I would call a GET method for the surface controller?
I can do this fine in regular MVC / .NET however I'm finding it a little difficult to do on Umbraco.
Thanks,
Wayne
Wayne,
Can you give a bit more context of what you are trying todo? It may that instead of a surfacecontroller you may need route hijacking? See https://our.umbraco.com/Documentation/Reference/Routing/custom-controllers-v7
Hi Ismail,
Thank you for your comment.
What I'm trying to do is creating a template page called manage in Umbraco with two toggle options of type bool.
When the user selects a bool option inside the manage page, the user clicks save and the page should reload, however when the page reloads the current values of the bool should be retrieved to check if the user has toggled some values already.
When the user goes to another page, such as "Sales", the sales page should get the bool values from the manage page before the sales page has loaded.
I was using a Surface Controller to achieve this, but the link you sent looks good to.
What's the difference between Surface controllers vs hijackings, do you have an example of when I use you a surface controller or hijacking?
Thanks,
Wayne
So looking at your situation I think you need a route hijack, this fires early in the page render, here you can check your property then render with appropriate template.
So coming back to webforms think of surface controllers and their related partials about like usercontrols. Where you need reusable components.
Hijacks are more page specific, so lets say you had blog page type and you want to list all comments for that blog page but the comments come from 3rd party system. So in this instance makes more sense to create a hijack of the route then for that page get its comments and add to the extended model for that page and pass it through.
Regards
Ismail
Interesting,
I've been looking into route hijacking, however for my model e.g
and my controller method
As seen in the below image I need to pass in two parameters, would you know how I would implement IPublishedContent and Culture info in my controller?
Thanks,
Wayne
Take a look at https://github.com/anthonydotnet/ubase its for v8 but there is example of a hijack and also what you have todo to the model etc.
Excellent, thank you
is working on a reply...