Skip to content

Instantly share code, notes, and snippets.

@ccamara
Last active December 19, 2015 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ccamara/6028592 to your computer and use it in GitHub Desktop.
Save ccamara/6028592 to your computer and use it in GitHub Desktop.
Display Suite's output modification in order to add a new class under certain circumstances #drupal #displaysuite
<?php
/**
* Implements hook_theme_registry_alter().
*/
function feature_blog_theme_registry_alter(&$theme_registry) {
$theme_registry['node']['preprocess functions'][] = 'onecolumn_class_node_preprocess';
}
/*
* Preprocess function for node.
* Added in feature_blog_theme_registry_alter()
*/
function onecolumn_class_node_preprocess(&$vars){
// If there's no content on the left column,
// we'll add a class to the node, for special CSS.
if ($vars['type'] == 'blog' && $vars['view_mode'] == 'teaser' && !$vars['left']) {
$vars['classes_array'][] = 'onecolumn';
}
}
@ccamara
Copy link
Author

ccamara commented Jul 18, 2013

We have to make sure that this module is loaded the last one in order to make sure that the new preprocess function gets loaded the last one.

This can be achieved by creating the following hook_update in module's module.install file:

<?php

/**
 * Increments nameofthemodule module's weight in system table.
 */
function nameofthemodule_update_7001(&$sandbox = NULL) {
  $fields = array(
      'weight' => '10',
    );

  db_update('system')
  ->fields($fields)
  ->condition('name', 'feature_blog')
  ->execute();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment