Created
October 28, 2014 04:28
-
-
Save nicksantamaria/27cb50525fb691d94cfd to your computer and use it in GitHub Desktop.
Stupid panels content categories getting you down?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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