View override

Topics: General, Writing modules, Writing themes
Mar 8, 2011 at 2:51 PM

Hi,

I've written a controller to override Orchard.Search, I'm wanting to use the exisiting views. I can achieve this with the following from my controller:

 

return View("Search/index", searchViewModel);

 

If the Orchard.Search view is overridden in a theme I need to use the following:

return View("Orchard.Search/Search/index", searchViewModel);

What i would like to do is have my controller use the Orchard.Search view by default but if the Orchard.Search view is overridden in a theme, then use the theme view.

Any idea on how i might be able to do this? I assume in the theme engine there must be a find view method i might be able to use to get the path...

Coordinator
Mar 8, 2011 at 6:22 PM

Mmmh, you shouldn't have to do anything further than indicate the name of the default view. If your controller is themed, the theme engine will just replace it with the best it has.