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

tim.plunkett’s picture

Right 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

dsnopek’s picture

This can also be done by using the Panels module and creating a new layout plugin! Although Panels for D8 is still super alpha.

baldwinlouie’s picture

Thanks for the suggestions. Actually, this was pretty simple. I had to extend BlockDisplayVariant, and override the getRegionNames() method from the BlockVariantTrait.

tim.plunkett’s picture

Status: Active » Fixed

Great!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

drupov’s picture

@baldwinlouie could you please write a short sample of this implementation?

dsnopek’s picture

While 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!