General

  eZ Systems Website
  Editor documentation


  Developer documentation

  Back to the top

Skip to end of metadata
Go to start of metadata

You can find all files used and modified in this step on GitHub.

In this step you'll add a Content List Block and two Schedule Blocks and customize them.

In this step pay close attention to the order of tasks. If you overlook a configuration file and try to generate a Landing Page without it, the Landing Page may become corrupted in the database. You may then get a 500 error when trying to access it. If this happens, you should delete the page and create it again from scratch.

Add Content List Block

At this point you can start adding blocks to the Landing Page. This is done in the Studio UI Edit mode by simply dragging the required block from the menu on the right to the correct zone on the page.

Content List block dragged onto a page

Not all the blocks we have planned are available to you just yet, so let's start with the simplest one. Drag a Content List Block from the menu to the right column, click the (still empty) block and enter its settings. Here you give a name to the block and decide what it will display. Choose the Dog Breed Catalog folder as the Parent, select Dog Breed as the Content Type to be displayed, and choose a limit. In our case we'll display the first three Dog Breeds we have in our database.

Window with Content List options

When you click Submit, you should see a preview of what the block will look like with the dog breed information displayed.

Content List UnstyledAs you can see, the block is displayed using a very basic, unstyled template. Built-in blocks have default templates already included in the installation, and it's this one that is being used right now. But you can override it according to your needs, and add templates for new custom blocks that you create (which we'll do in the next step). Publish the page now and we'll start configuring the block.

First let's create an override template for the Content List block. Create a blocks folder under app/Resources/views and place the new template file in it:

app/Resources/views/blocks/contentlist.html.twig

Then we add a configuration that will tell the app to use this template instead of the default one. Go to the layouts.yml file that you created previously when preparing the Landing Page layout and add the following code:

in app/config/layouts.yml

This block should be placed at the end of the file, within the ez_systems_landing_page_field_type key. Watch your indentation!

One more thing is required to make the template work. The twig file specifies an image alias – a thumbnail of the Dog Breed image that will be displayed in the block. To configure this image alias, open the app/config/image_variations.yml file and add the following code under the image_variations key (once again, mind the indentation):

in app/config/image_variations.yml

Finally, we should add some styling to the block. Add the following CSS to the end of the web/assets/css/style.css file:

in web/assets/css/style.css

If you refresh the front page now, you should see the new look of the Content List block.

Content List Styled

Create a Schedule Block for Featured Articles

The next block to go with is the Schedule Block that will air articles at predetermined times. We will actually use two different schedule blocks, so that you can learn how to customize their layouts and how to make use of the overflow functionality.

The process of creating a new layout may already look familiar to you. First, let's add a configuration that will point to the layout. Go to the layouts.yml again and add the following code under blocks:

in app/config/layouts.yml

As you can see, the configuration at this point defines one view for the schedule block that we called schedule_featured and points to a schedule_featured.html.twig file that will house its template. Place this new template file in app/Resources/views/blocks:

app/Resources/views/blocks/schedule_featured.html.twig

See the data-studio-slots-container (line 5) and data-studio-slot (line 7) attributes? Without them you won't be able to place Content in the slots of the Schedule Block, so don't forget about them if you decide to modify the template.

When you look at the template, you can see three blocks, each of which will render the Content items using the featured view. As you may remember, so far we only have templates for full view for Articles. This means we need to create a featured view template for it as well, otherwise we will get an error when trying to add Content to the block.

For the app to know which template file to use in such a case, we need to modify the views.yml file again. Add the following code to this file, at the same level as the full key:

in app/config/views.yml:

Now make a featured subfolder in the folder that houses your templates and create the following article.html.twig file in it:

app/Resources/views/featured/article.html.twig

Like in the case of the Content List block, the template specifies an image alias. Let's add it in app/config/image_variations.yml under the image_variations key:

in app/config/image_variations.yml

The Block would already be operational now, but let's first update the stylesheet. Add the following CSS to the end of the web/assets/css/style.css file:

in web/assets/css/style.css

At this point you can add this Schedule block to your Landing Page and fill it with content to see how it works.

Go to the Edit mode of the Front Page and drag a Schedule Block from the pane on the right to the main zone in the layout. Select the block and click the Block Settings icon. Choose the Featured Schedule Block template and confirm. We will only be able to set up overflow once we have both blocks ready.

Now click the Add content (plus) icon, navigate to and choose one of the Articles in the All Articles folder. You will see it appear in one of the slots in the preview. Now hover over this Article and click Airtime. Here you can choose the time at which this Content item will be published on the Landing Page. Do the same for two more Articles, so that all three slots are filled with content. Try to choose different airtimes for all three of them – you will then be able to see well how the Schedule block functions. Once you are done, take a look at the Timeline at the top of the screen. You can move the slider to different times and preview what the Schedule Block will look like at different hours, with content being hidden if you jumped to a point before its airtime.

At this point we have configured our Schedule Block to work well with Articles only. If you try to add Content of any other type, you will see an error. This is because there is no featured view for content other than Articles defined at the moment. If you'd like some more practice or want to make your website more foolproof, you can create such templates for all other Content Types in the database.

Front Page after adding Featured Block

Create a Schedule Block for Other Articles

Now we'll proceed with preparing the second Schedule Block for our Landing Page. The procedure will be very similar as in the first case. First, let's add the new block to configuration by adding this code to layouts.yml:

in app/config/layouts.yml

Next, we provide a template for the block:

app/Resources/views/blocks/schedule_list.html.twig

We also need a template for the list view for Articles:

app/Resources/views/list/article.html.twig

and an entry in views.yml:

in app/config/views.yml:

Like before, we must add one more image alias to the image_variations.yml file:

As the last thing, let's provide the new block with some styling. Add the following to the end of the web/assets/css/style.css file:

in web/assets/css/style.css

With this done, you should be able to add a new Schedule Block to the Front Page and select the List Schedule Block layout. Give the block an easily recognizable name, such as "Other Articles". Add two Articles to it to see how their look will differ from the featured ones.

The Page after adding a List Schedule Block

Set up overflow

Now let's make use of the overflow functionality. In the settings of the Featured Articles block turn on overflow and select the Other Articles block as its overflow target. This controls how content will behave once it has to leave the first block. This is behavior you are surely familiar with from many websites: we have placed featured articles in the first Schedule block and planned the times on which they will be aired. When a new article appears in this block, the last article currently in it will be 'pushed off' and will land in the block designated as the overflow block – that means in the list of articles below. In this way the most current articles are showcased at the top, while older articles are still easily accessible from the front page.

You can try this out now. Add one more Article to the Featured Articles block. You will see a message warning you that some content will be pushed out. When you confirm, the pushed out Article will move to the top of the Other Articles block.

Overflow push-out warning

 


 

Tutorial path

  • No labels