Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been trying to understand this for a while now, but I find the documentation either to lacking, or maybe I just don't understand what I'm looking for. Could anyone enlighten me on how to implement them?

One thing I'm trying to do is to be able to have contextual menus for each node in a list of nodes (loaded using node_load_multiple) that I'm sending along to a theme() function and looping through inside the .tpl.php

share|improve this question

I'll put my temporary solution here for now anyway in case it will help someone.

What I did was just creating a new theme function (?) in my module

$themes['contextual'] = array(
    'template' => 'contextual',
    'variables' => array('links' => array(), 'destination' => null)

Then I defined my contextual.tpl.php

<div class="contextual-links-wrapper">
    <ul class="contextual-links">
        <?php foreach($links as $url => $title): ?>
            <?php echo l($title, $url, 
                array('query' => array('destination' => $destination))) ?>
        <?php endforeach; ?>

Finally, to use it, wherever there is a need for a contextual menu, add the class contextual-links-region to the container div of the node (or whatever), and inside the div I use my function, for example:

<?php echo theme('contextual', array('destination' => 'node/'.arg(1),
    'links' => array('node/'.$somenode->nid.'/edit', t('Edit node')))); ?>
share|improve this answer
Is this solution working, Actually i need to use a context menu with one of my content type field. – Drupal Developer Jul 15 '14 at 16:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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