diff --git a/panels_ipe/panels_ipe.api.php b/panels_ipe/panels_ipe.api.php index bda971b..62550f3 100644 --- a/panels_ipe/panels_ipe.api.php +++ b/panels_ipe/panels_ipe.api.php @@ -41,3 +41,20 @@ function hook_panels_ipe_blocks_alter(array &$blocks = array()) { } } } + +/** + * Modify the list of layouts available through the IPE interface. + * + * @param array $layouts + * The layouts that are currently available. + * @param \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant $panels_display + * The current Panels display. + */ +function hook_panels_ipe_layouts_alter(array &$layouts, PanelsDisplayVariant $panels_display) { + // Only show layouts that are in the 'threecol' category. + foreach ($layouts as $key => $layout) { + if ($layout['category'] !== 'threecol') { + unset($layout[$key]); + } + } +} diff --git a/panels_ipe/src/Controller/PanelsIPEPageController.php b/panels_ipe/src/Controller/PanelsIPEPageController.php index b8c2e4c..6825c5c 100644 --- a/panels_ipe/src/Controller/PanelsIPEPageController.php +++ b/panels_ipe/src/Controller/PanelsIPEPageController.php @@ -180,6 +180,14 @@ class PanelsIPEPageController extends ControllerBase { ]; } + // Trigger hook_panels_ipe_layouts_alter(). Allows other modules to change + // the list of layouts that are visible. + \Drupal::moduleHandler()->alter('panels_ipe_layouts', $data, $panels_display); + + // Reindex the blocks after they were altered in case one of them was + // removed. + $data = array_values($data); + return $data; }