0

When editing/adding/removing tab links to a Node page (View/Edit) is there a quick way doing this with a hook_preprocess method and not via creating a module to alter them? Such as using hook_process_page() and then editing the $title_prefix array since this is where they are stored.

Example: I created a module for editing the contextual links, but what if I wanted to skip creating a module and directly inject my changes in the template.php via hook().

function mymodule_contextual_links_view_alter(&$element, &$items) {
      $element['#links']['new-links'] = array(
        'title' => 'Add something new',
        'href' => url('/admin/config/add/something/new', array('absolute' => TRUE)),
      );
    }

1 Answer 1

0

All _alter() hooks can be implemented by themes as well as modules, so in that specific case you can just use

function mytheme_contextual_links_view_alter(&$element, &$items) {
  ...
3
  • I see. What hook would you call to access the Node View/Edit tab links? Would it be something to do with the $title_prefix and using the hook_preprocess_page()? Thanks again for the info too.
    – tdm
    Commented Sep 11, 2013 at 18:28
  • You'd need to target the individual templates for those links (hook_preprocess_node(), hook_preprocess_block() maybe if that's applicable), but if the $title_prefix is structured in a way that you can alter then I say have at it
    – Clive
    Commented Sep 11, 2013 at 18:31
  • Ahhh ok. Think I'm getting close. Have another question but might need to open up a separate question for it. Thanks again for shining light on the direction!
    – tdm
    Commented Sep 11, 2013 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.