Created
January 16, 2012 16:07
-
-
Save egil/1621550 to your computer and use it in GitHub Desktop.
Drupal: Get contextual links on 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
// In template.php: | |
function THEME_menu_local_tasks($variables) { | |
// Add contextual links js and css library | |
drupal_add_library('contextual', 'contextual-links'); | |
$output = ''; | |
if (!empty($variables['primary'])) { | |
$variables['primary']['#prefix'] = '<div class="contextual-links-wrapper"><ul class="contextual-links">'; | |
$variables['primary']['#suffix'] = '</ul></div>'; | |
$output .= drupal_render($variables['primary']); | |
} | |
if (!empty($variables['secondary'])) { | |
$variables['secondary']['#prefix'] = '<ul class="tabs secondary clearfix">'; | |
$variables['secondary']['#suffix'] = '</ul>'; | |
$output .= drupal_render($variables['secondary']); | |
} | |
return $output; | |
} | |
// In page.tpl.php: | |
<div id="content" class="column"> | |
<div class="section contextual-links-region"> | |
<?php if ($page['highlighted']): ?><div id="highlighted"><?php print render($page['highlighted']); ?></div><?php endif; ?> | |
<a id="main-content"></a> | |
<?php print render($title_prefix); ?> | |
<?php if ($title): ?><h1 class="title" id="page-title"><?php print $title; ?></h1><?php endif; ?> | |
<?php print render($title_suffix); ?> | |
<?php if ($tabs): ?><?php print render($tabs); ?><?php endif; ?> | |
<?php print render($page['help']); ?> | |
<?php if ($action_links): ?><ul class="action-links"><?php print render($action_links); ?></ul><?php endif; ?> | |
<?php print render($page['content']); ?> | |
<?php print $feed_icons; ?> | |
</div> | |
</div> <!-- /.section, /#content --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment