sulu-workshop
sulu-workshop copied to clipboard
02 - Add a content block to the homepage
Add a content block to the homepage
Goal
Currently the content of our homepage consists of a single text editor and therefore lacks the possibility of managing different kinds of standardized content sections. We want to provide a way to manage content blocks such as image galleries or quotes to our content manager without having to worry about breaking the layout of our page.
Steps
- Add a new block with multiply types and the name
blocks
to theconfig/templates/pages/homepage.xml
file - Log into the admin UI with user "admin" and password "admin"
- Modify the "Homepage" and add some content blocks
- Render the created blocks in your
templates/pages/homepage.html.twig
Hints
Run bin/console sulu:content:types:dump
to list all available content types.
More Information
The block content type allows to define an arbitrary amount of block types. Each block type is a composition of multiple basic content types. After defining a block content type, the content manager is able to create and sort instances of the configured block types in the Sulu administration interface.
A common use case for the block content type is to group a text editor and a media selection. This allows to couple the respective text to the selected image and render it in a flexible and responsive way on your website. In contrast, adding images to a basic text editor makes it harder to adapt the format and placement in your twig template.
Links
- Next assignment pull request: 03 - Add a footer navigation to the website
- Source file of this assignment: assignments/02.md