Alright.. I've been trying to find an answer to this for days.. in IRC.. in documentation.. in articles about Display Suite.. and have had no luck. Whoever can answer this is my hero.

With the Display Suite module in D7, when I go to a layout, at the bottom I have a selection of pre-defined layouts. The Display Suite project page says I can "add custom layouts to my theme". HOW?!

I can't find any documentation, anywhere, on where I should place the tpl & css files, how I should name them, and how I should register them with Display Suite, so that they show up in that select box.

Example:

Display Suite includes a "3 Column 25/50/25" layout. I want to make a "3 Column 20/60/20" layout.

Comments

swentel’s picture

Hi, look at the ds.api.php file that comes in the module. The info is in that file.

jjma’s picture

Could you point out where in the ds.api.php file? Thought you could take the default 2-col layout and css files and drop them into your theme and edit to make changes.

Jon

scuba_fly’s picture

The file can be found in sites/all/modules/ds/ ( display suite root dir )

Freelance Drupal developer, contact me if you want help on your Drupal project.

runeasgar’s picture

Here's the relevant code:


/**
 * Themes can also define extra layouts.
 *
 * Create a ds_layouts folder and then a folder name that will
 * be used as key for the layout. The folder should at least have 2 files:
 *
 * - key.inc
 * - key.tpl.php
 *
 * The css file is optional.
 * - key.css
 *
 * e.g.
 * bartik/ds_layouts/bartik_ds/bartik_ds.inc
 *                            /bartik-ds.tpl.php
 *                            /bartik_ds.css
 *
 * bartik_ds.inc must look like this:
 *

  // Fuction name is ds_LAYOUT_KEY
  function ds_bartik_ds() {
    return array(
      'label' => t('Bartik DS'),
      'regions' => array(
        // The key of this region name is also the variable used in
        // the template to print the content of that region.
        'bartik' => t('Bartik DS'),
      ),
      // Add this if there is a default css file.
      'css' => TRUE,
    );
  }
sjozsi’s picture

I tried this. But I get an error message only.

// Fuction name is ds_LAYOUT_KEY function ds_sch_ds() { return array( 'label' => t('Bartik DS'), 'regions' => array( // The key of this region name is also the variable used in // the template to print the content of that region. 'bartik' => t('Bartik DS'), ), // Add this if there is a default css file. 'css' => TRUE, ); }
Fatal error: Call to undefined function ds_sch_ds() in /web/wopecs/wopecs7/sites/all/modules/ds/ds.registry.inc on line 371

or

function ds_sch_ds() { return array( 'label' => t('Two column, 100px left'), 'regions' => array( 'left' => t('Left'), 'right' => t('Right') ), 'css' => TRUE, ); }
Fatal error: Call to undefined function ds_sch_ds() in /web/wopecs/wopecs7/sites/all/modules/ds/ds.registry.inc on line 371

What is wrong?

sjozsi’s picture

Sorry!
The missed <?php tag.

scuba_fly’s picture

should it not be bartik_ds.tpl.php instead of bartik-ds.tpl.php ?
( underscore )

Freelance Drupal developer, contact me if you want help on your Drupal project.

Anonymous’s picture

mudassar774’s picture

Hi,

Anyone tried custom layout with Display suite in drupal 8. Or any suggestions how to do it. I tried with same D7 way but nothing happen really Nothing :(

thanks

rafaelferreir4’s picture

Could you create for D8? I have the same issue!

mudassar774’s picture

Yes I made it. Do you have still problem or you solved it. If yes share some details may I help and sorry for late reply. I couldn't come to this page for long time :)

digitaldonkey’s picture