Search code examples
drupal-6drupal-viewsdrupal-routes

Drupal: Create menu item for a view


I am creating a small reservation system. you can create nodes of a type that can be reservated, like a projector. I have a calendar view with normal displays. I addes an argument for the node reference, but I have problems defining the page callback. Can someone help me out?

Now I want to create menu items for the different nodes

function your_module_menu() {
$nodeid //semantic, node is loaded right
    $items['reservate/nodeid/$year-w$week'] = array( // semantic, url is built right
        'title' => t('Your Module Name'),
        'description' => t('Menu's description.'),
        'page callback' => 'page_callback_funtion',
        'page arguments' => array('page callback arguments'),
        'access callback' => 'your_module_access',           // the function that validates access based on the user's role(s).
        'access arguments' => array(array(role1', 'role2')), // list of roles authorized - note nested array.
        'type' => MENU_NORMAL_ITEM,
    );
    return $items;
}

@edit

ok, maybe I didn't explain well :). I have a content type: unit, which can be reserved. for each unit I create, I want to generate a menu item (I can do a menu rebuild on node save or update). the menu should be linked to a view, with the node id (unit) as an argument in the url.


Solution

  • I found a very simple way to do it, I just created a view-block which creates the links with some filters.

    simple and exactly what I needed, can't seem to understand why I didn't think of that sooner