Created
February 9, 2011 03:00
-
-
Save bangpound/817801 to your computer and use it in GitHub Desktop.
add manage field and display contextual links to nodes.
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 | |
/** | |
* Implement hook_menu_alter(). | |
*/ | |
function bangpound_menu_alter(&$items) { | |
if (module_exists('field_ui')) { | |
$items['admin/structure/types/manage/%node_type/fields']['context'] = MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE; | |
$items['admin/structure/types/manage/%node_type/display']['context'] = MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE; | |
} | |
} | |
/** | |
* Implement hook_node_view_alter(). | |
* | |
* Contextual links are added after hook_node_view() in node_view(), so | |
* use hook_node_view_alter() to add the node's links. | |
*/ | |
function bangpound_node_view_alter(&$build) { | |
$node = $build['#node']; | |
$view_mode = $build['#view_mode']; | |
if (!empty($node->nid)) { | |
// Field UI doesn't provide its own contextual links, so we pretend to be | |
// Field UI. This could backfire. | |
$build['#contextual_links']['field_ui'] = array('admin/structure/types/manage', array($node->type)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment