March 2019
Intermediate to advanced
580 pages
15h 3m
English
OK, but registering a layout doesn't help us with much. Unless, of course, we use Layout Builder or some contributed module that uses layouts for various things. In which case we'd already be providing great value. But what if we want to use this layout ourselves? In other words, render stuff with it.
The simplest way of rendering something with this layout could look like this:
$layoutPluginManager = \Drupal::service('plugin.manager.core.layout');
$layout = $layoutPluginManager->createInstance('two_column');
$regions = [
'left' => [
'#markup' => 'my left content',
],
'right' => [
'#markup' => 'my right content',
],
];
return $layout->build($regions);
Without going into too much detail about the plugin system (yet), but ...
Read now
Unlock full access