There is a module in Orchard CMS that allows for editing templates within the dashboard, however it is unclear how to properly utilize the output. What is the correct way to access a template in an MVC module controller, pass the template a model, and then render it within a View cshtml file?
0
votes
1 Answers
0
votes
You can build any shape with the shapefactory:
public MyController(IShapeFactory shapeFactory) {
Shape = shapeFactory;
}
public dynamic Shape { get; set; }
public ActionResult Index() {
var someModel = new SomeModel();
// You can build your shape here:
var shape = Shape.TheTemplateShapeName(SomeData: someModel.SomeProperty);
// or: Shape.New("TheTemplateShapeName").SomeData(someData);
// you can just chain on the dynamic shape
var viewModel = Shape
.ViewModel() // simple orchard method to build a viewmodel with chaining
.MyShape(shape)
.SomethingElse("Some string");
return View(viewModel);
}
Then in your MyController/Index.cshtml:
<h1>@Model.SomethingElse</h1>
@Display(Model.MyShape)