User login

Theming with Display Suite and Preprocess Functions

Display Suite does not use node-*.tpl.php. This would is be by design. There are three ways i see to bring in custom elements.

Custom fields

Typical usage for custom elements would seem to be creating entire custom 'fields' (as opposed to small variables) which can then be placed by Display Suite-- as shown in the first part of this post:

<?php
function mytheme_preprocess_node(&$vars) {
 
$vars['myfield'] = "Hello, world!";
}

function

mytheme_ds_fields_info($entity_type) {
 
$fields = array();
 
$fields['myfield'] = array(
   
'title' => t('My own preprocess field'),
   
'field_type' => DS_FIELD_TYPE_PREPROCESS,
  );
  return array(
'node' => $fields);
}
?>

Do not use display suite for a given view mode of a node

For Events, for instance, it is entirely custom and we probably don't want Display Suite involved at all.

It is possible to disable it at admin/structure/types/manage/event/display/full.

In the vertical taps at the bottom "Layout for event in full", the layout can be set to none.

Theme the applicable display suite template

However, we are already using Display Suite for events. So we can move the theming from node--event.tpl.php to a template used by displaysuite.

You have selected the Two column layout. The default template can be found in sites/all/modules/contrib/ds/layouts/ds_2col

Possible template suggestions are:

    ds-2col--node.tpl.php
    ds-2col--node-event.tpl.php
    ds-2col--node-event-full.tpl.php
Searched words: 
display suite and preprocess functions many ways to bring in custom code preprocessed data

Comments

How to: template suggestions

Hi. I am interested in what you are trying to do. I created a "test" content type and follow your outline in this post. I got template suggestions as:
ds-2col--node.tpl.php
ds-2col--node-test.tpl.php
ds-2col--node-test-full.tpl.php
When disabling ds by setting layout to "none" my theme template node.tpl.php
takes over from ds-2col--node.tpl.php .
You say "we are already using Display Suite for events. So we can move the theming from node--event.tpl.php to a template used by displaysuite."
But as I found out the case here is the with layout "none" we are not now
using a layout by ds.

So why "move the theming.. to a template used by ds"? ds is not involved
as you also say, at this point. And your layout is all custom. You must
have the event.tpl.php in your theme folder then to use it. So what is
it about "moving the theming". Sorry, I miss your point.
pls. comment!

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.