Right now I've done the following:

  • I've installed your module, made changes to template.php and configured the module via /admin/settings/menutrails. There I've assigned a parent item "Animal" to the content type "animal".
  • Then I've created a new primary menu item "Animals" which points to a view "view 1". When I click on the menu item the view is displayed and the item is marked as active (but I think this is a basic function of Drupal, right?).
  • Within View 1 I click on a link to a node "Dog" which is based on the content type "animal". Now the primary menu item is not marked as active anymore. But it should be...

It would be great if someone could tell me how to keep the primary menu item marked as active.

Comments

mvalverde’s picture

Status: Closed (won't fix) » Active

i've found a solution that works for me patching the menutrails.module

1 . Add the following functions for view handling to the module (right the same way they already exist for nodes) :

function menutrails_views_pre_view($view, $items) {
    if ($view->build_type == 'page') { 
      $location = menutrails_view_location($view);
      menu_set_location($location);
    }
}

// inspired by _menu_get_active_trail()
function menutrails_view_location($view) {
    $view_trails = variable_get('menutrails_views', array());
    $mid = $view_trails[$view->name];

    if ($mid > 0) {
      // Follow the parents up the chain to get the trail.
      while ($mid && ($item = menu_get_item($mid))) {
        $location[] = $item;
        $mid = $mid = $item['pid'];
      }
      $location = array_reverse($location);
      $location[] = array('path' => $view->url, 'title' => $view->title);
    }
    return $location;
}

2. Add following lines to the already existing 'menutrails_settings_form' function at appropiate place

  ...

  $view_urls = views_get_all_urls();
  $view_trails = variable_get('menutrails_views', array());

  ...

  $form['menutrails_views'] = array(
      '#tree' => TRUE,
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#title' => t('Menu trails by view'),
  );
  foreach ($view_urls as $key => $value) {
    $form['menutrails_views'][$key] = array('#type' => 'select',
      '#title' => t('Parent item for'). " $value",
      '#default_value' => $view_trails[$key],
      '#options' => $options,
    );
  }

  ...

Sorry for not delivering a patch;) But that should work!

Marco Valverde
www.explido-software.de

blackdog’s picture

This doesn't seem to work. Or could you perhaps explain how it's supposed to work, and how it works for you, mvalverde? Thanks.

sun’s picture

Status: Active » Closed (won't fix)

Sorry, Menu Trails for Drupal 5 is not actively developed/maintained anymore. Only issues containing patches may still be considered. Feel free to re-open this issue if you want to provide a patch.

Status: Active » Closed (won't fix)