Converting Search View MVC into Controller Rendering
I am trying to convert the view rendering for Search View MVC into a controller rendering but am having trouble passing the model to the view.
If I don't specify a model in my controller to pass when returning the view, the model will be null, otherwise I'm not sure how to retrieve a model for the search view
Here are the steps to set the view with the model.
- We create the view and Sitecore returns a Sitecore.Mvc.Presentation.Rendering object.
- We create the model using the Coveo.UI.Mvc.Models.SearchModel()
- We instantiate the model using the Sitecore Initialize method: myModel.Initialize(myViewRendering)
- This allow the Model to grab the parameters from the view.
- The view is rendered.
This said, you could instantiate the Sitecore.Mvc.Presentation.Rendering object by yourself (all the properties of the class are public) and then call the initialize method on our model. Just make sure that the Rendering object you created contains all the parameters that the model need.