Trouble with implementing contextual links I have a block with dynamic content and two contextual links.

I have at the moment two problems:


The second element is not visible.
The first link does not allow to pass a date. I have to set a prefix e.g. "_"


How can I fix this problems?

Here is the main part of my module:

define('MY_DIR', 'somedir');

function mymodule_menu() {
    $items[MY_DIR] = array(
        'page callback' =&gt; 'status_page',
        'access callback' =&gt; TRUE,
        'type' =&gt; MENU_LOCAL_TASK,
    );
$items[MY_DIR.'/%'] = array(
    'page callback' =&gt; 'status_page',
    'access callback' =&gt; TRUE,
);
    $items[MY_DIR.'/edit'] = array(
        'title' =&gt; 'Edit item',
        'page callback' =&gt; 'drupal_get_form',
        'page arguments' =&gt; array('mymodule_object_edit_form', 2),
        'access callback' =&gt; TRUE,
        'type' =&gt; MENU_LOCAL_TASK,
        'context' =&gt; MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
    );
    $items[MY_DIR.'/%date/update'] = array(
        'title' =&gt; 'Edit date',
        'page callback' =&gt; 'drupal_get_form',
        'page arguments' =&gt; array('mymodule_object_edit_form', 2),
        'access callback' =&gt; TRUE,
        'type' =&gt; MENU_LOCAL_TASK,
        'context' =&gt; MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
    );

    return $items;
}


And here is my status page:

function status_page($date=null) {
    $object=new stdClass();
    $build=array();

    if(empty($date)) {
        $day=get_next_match();
    } else {
        // parse data
    }

    // set title
    $title="Title for ".$day-&gt;format("j.m.Y");
    drupal_set_title($title);

    $object-&gt;title = $title;
    $object-&gt;content = "Some dynamic content";

    $build[0] = array(
        '#theme' =&gt; 'filteredusers_object',
        '#object' =&gt; $object,
        '#contextual_links' =&gt; array(
            // contextual link 1
            'update-option' =&gt; array(
                MY_DIR,
                array("_$date"),
            ),
            // contextual link 2
            'edit.option' =&gt; array(
                MY_DIR.'/edit',
                array(),
            ),
        ),
    );
    return $build;
}


If something is unclear feel free to ask.
After one day of research I got a solution:

$build[1] = array(
    '#theme' =&gt; 'filteredusers_object',
    '#object' =&gt; $object,
    '#contextual_links' =&gt; array(array('', array())), // replaced by dummy data
    '#marker' =&gt; 'marker',
);


And adding this new hook:

function filteredusers_contextual_links_view_alter(&amp;$element, &amp;$items) {
    if(isset($element['#element']['#marker']) &amp;&amp; 
             $element['#element']['#marker'] == "marker") {
        $element['#links']['custom-link'] = array(
            'title' =&gt; 'Some title',
            'href' =&gt; url('node/42', array('absolute' =&gt; TRUE)),
        );
    }
}