Created
April 9, 2014 01:59
-
-
Save jtwalters/10218769 to your computer and use it in GitHub Desktop.
A really deep Drupal conditional to hide Manage Display (display suite)
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 | |
/** | |
* Selectively hide the "Manage Display" local task added by Display Suite | |
* @see hook_menu_local_tasks_alter | |
*/ | |
function HOOK_sitewide_tweaks_menu_local_tasks_alter(&$data, $router_item, $root_path) { | |
// If we're on a node page | |
if (isset($router_item['path']) && $router_item['path'] == 'node/%') { | |
// If page_arguments exists | |
if (isset($router_item['page_arguments']) && is_array($router_item['page_arguments'])) { | |
// If tabs array exists | |
if (isset($data['tabs']) && is_array($data['tabs']) && is_array($data['tabs'][0])) { | |
// If tabs output array exists | |
if (isset($data['tabs'][0]['output']) && is_array($data['tabs'][0]['output'])) { | |
// Iterate through tabs to find the Manage Display tab | |
foreach ($data['tabs'][0]['output'] as $k => $tab) { | |
if ($tab['#link']['path'] == 'node/%/display') { | |
unset($data['tabs'][0]['output'][$k]); | |
} | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment