Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
when you hijack a route, instead of returning the original view, is it possible to return a different view if a parameter is passed into the extended RenderMvcController?
Thanks a lot!
Hi Damon
Yes, so if you are using CurrentTemplate
return CurrentTemplate(model);
This will return the View the original node is based on, but as this is MVC you can just return using View eg:
return View("MyOtherView", model);
so
public ActionResult Index(RenderModel model, int SomeParameter = 1) { var customModel = new CustomModel(model.Content, CultureInfo.CurrentCulture); if (someParameter == 1){ return View("MyOtherView", customModel); } else { return CurrentTemplate(customModel); } }
You can also cause an umbraco node to load an alternative template using ?altTemplate=templateAlias on the querystring
and you can create an ActionResult that matches the template alias to hijack the alternative template route.
Excellent thanks!
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Question on hijacking routes
Hi,
when you hijack a route, instead of returning the original view, is it possible to return a different view if a parameter is passed into the extended RenderMvcController?
Thanks a lot!
Hi Damon
Yes, so if you are using CurrentTemplate
This will return the View the original node is based on, but as this is MVC you can just return using View eg:
so
You can also cause an umbraco node to load an alternative template using ?altTemplate=templateAlias on the querystring
and you can create an ActionResult that matches the template alias to hijack the alternative template route.
Excellent thanks!
is working on a reply...