Create the layout file
To create layout files, perform the following:
-
In Visual Studio, open your SitefinityWebAppproject » ResourcePackages » [YourPackage].
For more information, see Overview: Resource packages.NOTE: You can also create the layout file in the root folder of your project:
~/MVC/Views/Layouts. For more information, see Priorities for resolving views. -
Create new folder and name it Layouts .
-
In the context menu folder Layouts, and click Add » Code File.
-
Name the file in the same way that you named your page template.
For example, if the page template is named mypagetemplate, you must name the layout filemypagetemplate.cshtmlNOTE: The file extension of the layout file depends on the type of view engine you are using. For example, when using Razor view engine, you need to have a .cshtml layout file extension.
NOTE: Replace all special characters in the file name with an underscore “
_”. -
Open the layout file you created and paste the following markup:
HTML+Razor@using Telerik.Sitefinity.Frontend.Mvc.Helpers <!DOCTYPE html> <html> <head> <title></title> </head> <body> <h1>Template based on Layout file by convention</h1> <div> @Html.SfPlaceHolder("Contentplaceholder1") @Html.SfPlaceHolder("Contentplaceholder2") @Html.SfPlaceHolder("Contentplaceholder3") </div> </body> </html> -
In the markup above, you specify the following layout file content:
usingdirective forTelerik.Sitefinity.frontend/Mvc/Helpersnamespace- Document type tag
<!DOCTYPE html> <head>tag<body>tag- Placeholders inside the
<body>tag that you create by using a helper method@Html.SfPlaceHolder()that result in drop zones in the corresponding template in the Sitefinity CMS user interface
The helper method accepts the name of the placeholder as an optional parameter.
-
Save the file.
RESULT: After Sitefinity CMS restarts, it automatically creates a new page template with a name corresponding to the layout file you created. You can work with the page template straight away by navigating to Design » Page templates.