This project is read-only.

Using html.action on views of admin pages? Common view for more admin pages.

Topics: Customizing Orchard, Writing modules
Jul 25, 2014 at 11:38 AM

I need to use one common view(custom extends form needed for administration all my widgets) for more admin pages(EditorTemplates/Parts).
So I tried @Html.Action with err:
The controller for path '/Alanis.Orchard/Admin/Widgets/EditWidget/5' was not found or does not implement IController.
Than tried prepare some helper to App_Code, but not found problem.

What is the best practicies to use one view for common code in more admin pages?

Thanks for any help.
Jul 25, 2014 at 4:56 PM
Do you have a controller? It is like MVC. No controller no view...
Jul 25, 2014 at 9:59 PM
Yes, I have controller. I thing that IController problem raise Orchard core, cose admin dont implement IController. Its it? Exists any way to use html.action in admin? Or some better possibility?
Jul 31, 2014 at 9:16 AM
Aug 1, 2014 at 1:21 AM
Edited Aug 1, 2014 at 1:21 AM
One way to use one common view is to use a wrapper template. So your UI s rendered using shapes, and those shapes use a wrapper.
For example, from your controller action:
var myUI = _orchardServices.New.MyUI();
return new ShapeResult(this, myUI);
Your MyUIWrapper.cshtml file would look like this:
<h1>Some header sample</h1>
<footer>Some sample footer</footer>
Now you can render any UI and use the same wrapper for them.

Another but similar way is to simply new up a shape called MyUIWrapper and add your UI shapes to it. For example:
var myWrapper = _orchardServices.New.MyUIWrapper();
return new ShapeResult(this, myWrapper);
In MyUIWrapper.cshtml:
<h1>Some header sample</h1>
<footer>Some sample footer</footer>