ByteEditor Website Builder
Create layout
By following the steps in this instruction, you will be able to create your custom four-column layout. You can use the code snippets provided in the guide to recreate this layout, or you can modify the steps to tailor the layout to your specific needs.
In order to create a layout, for example, Four Columns Layout, we need a back office preview (a Lit custom view registered in an “umbraco-package.json” file), an element type, and a front-end view.
Step 1. Back office preview
- Open the project folder
- Open the “App_Plugins” folder
- Create a folder for custom layouts, for example, name “CustomBlockView”
- Create a file named “four-column-layout.custom-view.js”
- Copy the following code and paste it into the file
6. Create a file named “umbraco-package.json” in the “CustomBlockView” folder
7. Add the following JSON to the file:
💡 There is no build step: Umbraco 17 loads these files directly. “forContentTypeAlias” must match the element type alias you create in Step 2. To learn more, see the Umbraco documentation on custom views for blocks.
Step 2. How to create a layout in Umbraco
- Run your project locally where the ByteEditor 17.X package is installed.
- Open the “Settings” section.
- Expand “Document Types” → “Blocks”.
- Hover over the “Layouts” folder, click '...' and choose “Create”.
- Select “Element Type”.
- Name it “Four Columns Layout”.
- Click the icon next to the name and pick an icon for the layout.
- Next to the name, change the alias from “fourColumnsLayout” to “fourColumnsLayoutBlock”.
- Click “Add group” and name the group “Content”.
- Click “Add property”, name it “Background picture” (alias “backgroundPicture”).
- Click “Select property editor” and choose “Image Media Picker”, then “Submit”.
- Click “Compositions”.
- Under “Blocks/Compositions”, select “Section Margins”, “Section Settings” and “Section Custom CSS for elements”.
- Click “Submit”, then “Save”.
Step 3. How to add Layout to the Block Grid
- Open “Settings” → “Data Types” → “Home - Main Grid - Block Grid”.
- Click “Add block” and choose “Four Columns Layout”.
- Put it in the “Layout” group.
- Turn on “Allow at root” and turn off “Allow in areas”.
- Open “Areas” and add four areas with the aliases “first”, “second”, “third” and “fourth”, each 3 columns wide.
- Click “Submit”, then “Save”.
💡 Unlike Umbraco 13, there is no “Custom view” field on the block: the preview is picked up automatically from “umbraco-package.json” by the element type alias.
Step 4. How to create a Layout view on the front end
- In “Settings”, expand “Partial Views” → “blockgrid”.
- Hover over the “Components” folder, click '...' and choose “Create” → “Empty partial view”.
- Name it “fourColumnsLayoutBlock.cshtml”.
- Copy the following code and paste it into the file
5. Click “Save”
6. Restart the project so ModelsBuilder generates the “FourColumnsLayoutBlock” model
Congratulations!
You have created your first layouts. Now you can add it to your page and fill with the elements.
The result of the work done!