Hello,

Is there a way to remove the default layouts provided by panels ? I would like to write my own and see only my own layout when I click on the layout link of the in-place editor.

I know I could delete the panels.layouts.yml, but I would use a method that is upgrade proof.

In the 7.x version of panels, we had an admin interface to select the layout we want to see available, is there an equivalent for d8 ?

Thanks

Alex

Comments

Alexandre360 created an issue. See original summary.

othermachines’s picture

Just figured this out myself. Unfortunately there doesn't appear to be an interface for that (yet) in D8. I implemented the following hook (provided by layout_plugin) in a custom module.

Edit: Updated - there are now (since Layout discovery replaced Layout plugin) fewer default layouts and their names are now prefixed with "layout_".

/**
 * Implements hook_layout_alter().
 */
function mymodule_layout_alter(&$definitions) {
  // Disable default layouts.
  unset($definitions['layout_onecol']);
  unset($definitions['layout_twocol']);
  unset($definitions['layout_twocol_bricks']);
  unset($definitions['layout_threecol_25_50_25']);
  unset($definitions['layout_threecol_33_34_33']);
}

Hope that helps.

DamienMcKenna’s picture

thomas.frobieter’s picture

Should #2 still work?

I got: "Drupal\Component\Plugin\Exception\PluginNotFoundException: The "layout_onecol" plugin does not exist. in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 52 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php)."

If i print out $definitions with kint, i can see "layout_onecol" etc.

thomas.frobieter’s picture

Okay, it does work for every other layout except "layout_onecol" - maybe because this is already set as default everywhere. But i'm fine with it.

othermachines’s picture

Hi, @thomas.frobieter. I think you already figured this out, but I believe you're getting the error because it *is* working (you're unsetting it, so it doesn't exist). It should disappear if you change the defaults.

wereallmonks’s picture

#2 still applies. I'm running some DS extras as well, so I had to add the select DS layouts in the same manner to unset those too.

rodpal’s picture

I'm using hook_plugin_filter_TYPE__CONSUMER_alter(array &$definitions, array $extra) to avoid error width default layout: "layout_onecol"

/**
 * Implements hhook_plugin_filter_TYPE__CONSUMER_alter(array &$definitions, array $extra).
 * @param $definitions
 */

function layout_classes_plugin_filter_layout__layout_builder_alter(&$definitions) {
  unset($definitions['layout_onecol']);
  unset($definitions['layout_twocol']);
  unset($definitions['layout_twocol_bricks']);
  unset($definitions['layout_threecol_25_50_25']);
  unset($definitions['layout_threecol_33_34_33']);
}