Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Answer for question on Drupal Stack Exchange:
- // http://drupal.stackexchange.com/questions/27907/enable-a-nodes-menu-item-when-on-that-node
- // this is the template.php file!!
- // ....
- /**
- * @see http://api.drupal.org/api/drupal/includes!theme.inc/function/theme_link/7
- */
- function YOURTHEMENAME_link($variables) {
- // in this example, I let "node/425" link only be visible if the user is on this page
- $your_paths_to_hide_array = array('node/425'); // empty cache every time you change that
- $link_also_visible_on_paths = array(); // empty cache every time you change that
- $is_link_to_hide = in_array($variables['path'], $your_paths_to_hide_array);
- if ($is_link_to_hide) {
- $is_current_page_self = ($variables['path'] == $_GET['q']);
- $element_can_be_visible = $is_current_page_self || (!empty($link_also_visible_on_paths) && in_array($_GET['q'], $link_also_visible_on_paths));
- if (!$element_can_be_visible) {
- return '';
- }
- }
- return '<a href="' . check_plain(url($variables['path'], $variables['options'])) . '"' . drupal_attributes($variables['options']['attributes']) . '>' . ($variables['options']['html'] ? $variables['text'] : check_plain($variables['text'])) . '</a>';
- }
- // ....
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement