Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
I am exploring using Page Manager on a project. I wanted to know if there is a way to define more regions for blocks? Currently, I can only place blocks in the "top" and "bottom" region.
Is there a recommendation on how to do this?
Comments
Comment #1
tim.plunkettRight now it cannot be done in the UI. You'd need to add your own block variant.
See
\Drupal\page_manager\Plugin\BlockVariantInterface::getRegionNames
and
\Drupal\page_manager\Plugin\BlockVariantTrait::getRegionNames
Comment #2
dsnopekThis can also be done by using the Panels module and creating a new layout plugin! Although Panels for D8 is still super alpha.
Comment #3
baldwinlouie CreditAttribution: baldwinlouie commentedThanks for the suggestions. Actually, this was pretty simple. I had to extend BlockDisplayVariant, and override the getRegionNames() method from the BlockVariantTrait.
Comment #4
tim.plunkettGreat!
Comment #6
drupov CreditAttribution: drupov commented@baldwinlouie could you please write a short sample of this implementation?
Comment #7
dsnopekWhile creating your own display variant would definitely work, and is certainly fine for now (especially while everything is still so alpha), the "way of the future" is using Layout Plugin to provide new layouts:
https://www.drupal.org/project/layout_plugin
This is what both Panels and Display Suite use, although, if you want to avoid them (because they are also still very alpha), you can just use the "Block page (with Layout plugin support)" variant from the 'block_page_layout' module that comes with layout_plugin.
layout_plugin allows you to provide new layouts by simply including a *.layouts.yml file and Twig template in your module or theme.
I hope that helps!