Panels has this super useful code that other modules can use to add or remove classes to the body tag:

/**
 * Remove default sidebar related body classes and provide own css classes
 */
function panels_preprocess_html(&$vars) {
  $panel_body_css = &drupal_static('panel_body_css');
  if (!empty($panel_body_css['body_classes_to_remove'])) {
    $classes_to_remove = explode(' ', $panel_body_css['body_classes_to_remove']);
    foreach ($vars['classes_array'] as $key => $css_class) {
      if (in_array($css_class, $classes_to_remove)) {
        unset($vars['classes_array'][$key]);
      }
    }
  }
  if (!empty($panel_body_css['body_classes_to_add'])) {
    $vars['classes_array'][] = check_plain($panel_body_css['body_classes_to_add']);
  }
}

I think it would be really nice if this functionality was available for many more modules to use in CTools. I've adapted my custom functions and converted them to CTools.

CommentFileSizeAuthor
#1 1775660-class-helpers.patch2.8 KBDave Reid
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid’s picture

Status: Active » Needs review
FileSize
2.8 KB

Patch attached for initial review and approval before I continue with writing tests and/or re-rolling for Drupal 8.

merlinofchaos’s picture

Status: Needs review » Fixed

Okay, I'm feeling really bad for not having seen this earlier!

Committed and pushed. We will probalby want to retool Panels to use this instead, but we have to be wary because we don't want to just break people who update Panels but not CTools.

merlinofchaos’s picture

Oh incidentally I also upped the CTools API version and edited API.txt to mention the introduction of the new functions.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

andypost’s picture

Priority: Normal » Critical
Status: Closed (fixed) » Active

The issue introduces huge performance regression and was commited within #1763746: Double returns in user_edit argument.
ctools_process() is called for each renderable and most of this calls are useless.
Suppose better to revert commit http://drupalcode.org/project/ctools.git/commit/12d6b1d and then commit actual changes from #1763746: Double returns in user_edit argument.

MustangGB’s picture

Issue summary: View changes
Priority: Critical » Normal
Status: Active » Fixed

I'm guessing this is solved by now as there doesn't appear to be any huge performance issues presently.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.