2

I am using Display Suite and I created a custom layout called ds_6row when I Flush Cache I get the following error

Call to undefined function ds_ds_6row() in /Users/myname/Sites/sitename/sites/all/modules/contrib/ds/includes/ds.registry.inc on line 570

I followed the method to create the layout here

My structure looks like this:

mytheme
--ds_layouts
---ds_6row
----ds_6row.css
----ds_6row.inc
----ds_6row.png
----ds-6row.tpl.php

The code for ds_6row.inc is:

<?php
function ds_6row() {
  return array(
    'label' => t('6 Row Layout'),
    'regions' => array(
    'info_data' => t('Info_data')
  ),
// Add this line if there is a default css file.
'css' => TRUE,
// Add this line if you're using DS 2.x for icon preview
'image' => TRUE,
);
}

The code for ds-6row.tpl.php is:

    <?php

/**
 * @file
 * Display Suite 6 row template.
 */
?>
<<?php print $layout_wrapper; print $layout_attributes; ?> class="ds-6row <?php print $classes;?> clearfix">

  <?php if (isset($title_suffix['contextual_links'])): ?>
  <?php print render($title_suffix['contextual_links']); ?>
  <?php endif; ?>

  <<?php print $first_wrapper ?> class="group-first<?php print $first_classes; ?>">
    <?php print $first; ?>
  </<?php print $first_wrapper ?>>

  <<?php print $second_wrapper ?> class="group-second<?php print $second_classes; ?>">
    <?php print $second; ?>
  </<?php print $second_wrapper ?>>

  <<?php print $third_wrapper ?> class="group-third<?php print $third_classes; ?>">
    <?php print $third; ?>
  </<?php print $third_wrapper ?>>

  <<?php print $fourth_wrapper ?> class="group-fourth<?php print $fourth_classes; ?>">
    <?php print $fourth; ?>
  </<?php print $fourth_wrapper ?>>

  <<?php print $fifth_wrapper ?> class="group-fifth<?php print $fifth_classes; ?>">
    <?php print $fifth; ?>
  </<?php print $fifth_wrapper ?>>

  <<?php print $sixth_wrapper ?> class="group-sixth<?php print $sixth_classes; ?>">
    <?php print $sixth; ?>
  </<?php print $sixth_wrapper ?>>

</<?php print $layout_wrapper ?>>

<?php if (!empty($drupal_render_children)): ?>
  <?php print $drupal_render_children ?>
<?php endif; ?>
2

Have a look in the code for Display Suite, specifically the block mentioned in the error message:

function _ds_layouts_scan_theme($theme, &$layouts) {
  $theme_layouts = file_scan_directory(drupal_get_path('theme', $theme) . '/ds_layouts', '/inc$/');
  foreach ($theme_layouts as $file => $values) {
    include_once(DRUPAL_ROOT . '/' . $file);
    $function = 'ds_' . $values->name;
    $layouts[$values->name] = $function();
    $layouts[$values->name]['path'] = str_replace('/' . $values->filename, '', $file);
  }
}

Note that when it goes looking for layouts is it prepending your layout name with 'ds_'.

I imagine this is to prevent functions being included that were not intended for this purpose, a bit like using your module name in place of hook_ when you implement hooks.

That's why changing your function name worked.

  • 1
    Exactly, +1. It takes the file name and preprends ds_ onto it to get the function name to call. And even the documentation referred to makes this naming pattern clear enough. – J. Reynolds Dec 17 '14 at 5:07
  • It is clear enough in the documentation if you know what to look for, I was flummoxed by this kind of thing only a few months ago so I'm happy to point out the solution on occasion =) – Darvanen Dec 17 '14 at 5:10
0

I got it to work by editing ds_6row.inc. I changed

<?php function ds_6row() {

to

<?php
function ds_ds_6row() {

If anyone can tell me why this worked. I'll be a happy man.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.