How to Create Sitecore MVC Layout and Controller Rendering

2017/12/152 min read
bookmark this
Responsive image

Table of Contents

  1. Introduction
  2. Create a Sitecore Page with MVC Layout and Controller
  3. Create Layout at Sitecore
  4. Set Sitecore Location for New Layout File
  5. Set Sitecore MVC Layout's cshtml File Location
  6. Create New DefaultLayout1.cshtml in Visual Studio
  7. Sitecore Layout Detail
  8. DefaultLayout1.cshtml Detail
  9. Create Sitecore Controller Rendering
  10. Add Controller Name and Action Name in Sitecore
  11. Create Controller in Visual Studio MVC Project
  12. Sitecore Page Layout Detail
  13. Change Sitecore Page to Use Different Layout
  14. Layout Detail - Add Sitecore Controller Rendering
  15. Device Editor
  16. Select the New Rendering
  17. Sample Controller Rendering
  18. Page Using New Layout and New MVC Controller
  19. Create New Page and Submit via Workflow
  20. Approve Workflow
  21. Publish and See Changes
  22. Conclusion

Introduction

This blog demonstrates how to create and use MVC Layout and Controller with Sitecore Layout and Controller Rendering. The final source code can be obtained from the link provided.

Create a Sitecore Page with MVC Layout and Controller

Create Layout at Sitecore

Set Sitecore Location for New Layout File

Set Sitecore MVC Layout's cshtml File Location

Create New DefaultLayout1.cshtml in Visual Studio

Sitecore Layout Detail

DefaultLayout1.cshtml Detail

Create Sitecore Controller Rendering

Add Controller Name and Action Name in Sitecore

Create Controller in Visual Studio MVC Project

Sitecore Page Layout Detail

Change Sitecore Page to Use Different Layout

Layout Detail - Add Sitecore Controller Rendering

Device Editor

Select the New Rendering

Sample Controller Rendering

Page Using New Layout and New MVC Controller

Create New Page and Submit via Workflow

Approve Workflow

Publish and See Changes

Conclusion

This walkthrough covered the complete process of creating Sitecore MVC Layouts and Controller Renderings, from setting up the layout and controller in both Sitecore and Visual Studio, to publishing the final page through the workflow.