Multiple custom layouts work slightly different

Last updated on
30 April 2025

To have multiple custom layouts is not as straight forward than just adding another custom layout's folder and files to the sites/all/theme/mytheme folder. Chances are you'll end up with the WSOD.

Follow the steps on the previous page to create one custom layout with some naming changes:

Give a more general name that will be used for the:

  • Folder
  • The name in the theme.info file.
  • In the name of the function in the inc file

For instance:
In folder customlayout you have:

  • customlayout1.inc
  • customlayout1.png
  • customlayout1.css
  • customlayout1.tpl.php

Where customlayout1 is of course the name of your layout. In the previous page this was onerowtwocols.

In the mytheme.info file you use:
plugins[panels][layouts] = customlayout

Your customlayout.inc file will look like this:

function mytheme_customlayout1_panels_layouts() {
  $items['customlayout1'] = array(
    'title' => t('Custom Layout 1'),
    'icon' => 'customlayout1.png',
    'theme' => 'customlayout1',
    'css' => 'customlayout1.css',
    'panels' => array(
      'left' => t('Left side'),
      'right' => t('Right side')
    ),
  );
  
  return $items;
}

Create the files for your next custom layout, buy you don't need to create another folder. Instead, put all files in the customlayout folder.

Add another customlayout.inc

function mytheme_customlayout2_panels_layouts() {
  $items['customlayout2'] = array(
    'title' => t('Custom Layout 2'),
    'icon' => 'customlayout2.png',
    'theme' => 'customlayout2',
    'css' => 'customlayout2.css',
    'panels' => array(
      'left' => t('Left side'),
      'right' => t('Right side')
    ),
  );
  

So, now in folder customlayout you have:

  • customlayout1.inc
  • customlayout1.png
  • customlayout1.css
  • customlayout1.tpl.php
  • customlayout2.inc
  • customlayout2.png
  • customlayout2.css
  • customlayout2.tpl.php

Help improve this page

Page status: Not set

You can: