Sitecore renderings are the way developers can render a page or a part
of a page in Sitecore.
Sitecore has many different types of renderings but when we work with MVC, the two main renderings.
In View Rendering, Sitecore has many different types of renderings but when we work with MVC, the two main renderings.
- view renderings
- controller renderings
View rendering can be used for components that have no logic in it. Simply view rendering is like calling a partial view in MVC, basically, it doesn't have a controller. View rendering works with a .cshtml view file and registering it with Sitecore.
Go to Layouts->Renderings section, right click on Renderings and select Insert->View Rendering. Give some name as "MyviewRendering" and with below mentioned field values:
- Path : Path to the razor view file i.e., “/Views/MyviewRendering.cshtml“.
- Model : Click on insert link and select the sitecore Model we have created ‘MySitecoreModel’.
- PlaceHolder : This is the placeholder in the Layout file where this view rendering should be rendered.
- Template : this is the template where this view use the fields for using to create any item.
Controller rendering, has a controller and subsequently needs a little bit more configuration and code. controller rendering specifies a controller name and an action name
Create Controller name with MyController.cs
Create View for that controller with named MyView.cshtml
Go to Layouts->Renderings, right click on Renderings, click on Insert->Controller Rendering. Give some name as "MycontrollerRendering" and with below mentioned field values:
-
Controller: My,
Controller Action: Action(Method) Name
- Save and publish the item.
- Select any item in home node.
- Go to Presentation->Detail
Layout Detail Popup will Appear. You Can Add/Edit your rendering here with placeholder.
Comments and suggestions are most welcome. Happy coding!
No comments:
Post a Comment