Skip to content

Instantly share code, notes, and snippets.

@nicksantamaria
Created October 28, 2014 04:28
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 nicksantamaria/27cb50525fb691d94cfd to your computer and use it in GitHub Desktop.
Save nicksantamaria/27cb50525fb691d94cfd to your computer and use it in GitHub Desktop.
Stupid panels content categories getting you down?
<?php
/**
* @file
*
* Replaces all of the panels content categories with a single "All" tab.
*
* To enable, simply do the following:
* - Search & replace "example" with your module name.
* - Run `drush vset example_panels_all_category 1`
* - Clear your caches.
*
* To disable, run the following drush command:
* - drush vdel example_panels_all_category
*/
/**
* Implements hook_ctools_content_subtype_alter().
*/
function example_ctools_content_subtype_alter(&$subtype, $plugin) {
if (variable_get('example_panels_all_category', FALSE)) {
// Put all the content options into an "All" container.
$subtype['category'] = 'All';
// Use a custom preview render callback which just prints out the basic
// identifier, rather than trying to render it.
$subtype['render callback'] = 'example_ctools_render';
}
}
/**
* Custom preview render callback for panels "add content" interface.
*
* @see example_ctools_content_subtype_alter().
*/
function example_ctools_render($not_sure) {
// Printing out the delta rather than a rendered preview.
$block->content = '<p>' . $not_sure . '</p>';
$block->delta = '';
return $block;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment