Hello,
I'm currently using Panels2 in my Drupal 6 site to do a node-override for a couple node types. The overridden nodes don't seem to respond to Menu Trails settings. If I disable Panels, Menu Trails works as expected for each type.

Would it be possible to allow Menu Trails to set the menu parents and breadcrumbs for Panel Pages that are catching certain node types?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

geraud’s picture

I face this problem in Drupal 5 too.
Actually, I have Menu Trails up and running and I have primary links displayed on node pages.
But when I override a node type with panels, primary links disappear on node pages.

mikeytown2’s picture

It has to do with incomplete support for hook_nodeapi() in Panels
http://drupal.org/node/364280

The workaround if there is one, would be to replicate what this module does in it's hook_nodeapi() in hook_init() function. Accessing $node is the main issue in regards to hook_init(). I've stopped working on this, since it's low on my priority list. You can see that right now it's is a code workaround for Organic Groups. The same would have to be done for Panels

drewish’s picture

well panels2 is really broken and is being overhauled for panels 3. so i'd argue against adding any special case code for it.

fuerst’s picture

FileSize
643 bytes

Nodes overwritten by Panels node_view still have the node/<nid> URL internally. You can get the $node object by calling node_load() using arg(1) for the nid.

The attached patch modifies Menu Trails by loading the $node object in menutrails_init() and calling menutrails_nodeapi() to let it do the node related stuff.

That still applies to node_view overrides only and not to any other Panel page though. That's another interesting and much needed topic.

rburgundy’s picture

Status: Active » Needs review

subscribing

pvasener’s picture

Status: Needs review » Reviewed & tested by the community

I have tested this patch and it corrects the bug on my system.

pvasener’s picture

FileSize
642 bytes

Just a small glitch in the patch though (deprecated by-reference parameter). Here is a fixed one.

xmark99’s picture

Patch #7 worked for me. Thank you so much as this was very much needed since I override all of my node views with Panels.

It will be great addition to the next version of Menu Trails, please :)))))))))

Thanks again.

jcisio’s picture

Patch applies well for 6.x-1.x-dev and works with Panels 3.x.

alexpott’s picture

Patch #7 worked well for me too - good work!

nedjo’s picture

You can get breadcrumbs working by adding the "Node content" pane to your panel and selecting the option to "Treat this as the primary node page", which triggers hook_nodeapi's view op.

fuerst’s picture

That's good to know.

You may also use the modul menu_breadcrumb which does not depend on invocation of hook_nodeapi because it uses hook_init to set the breadcrumb. If you already use the modul custom_breadcrumbs 6.x-2.0-beta2 you may use it's similar working option called Use the menu structure to set the breadcrumb trail.

sun’s picture

Status: Reviewed & tested by the community » Needs work

This may work, but is not a proper fix. It means we would invoke our functionality twice on regular node pages, just because Panels module is installed.

Instead, we need a deeper integration into Panels, resp. Page manager, to invoke our functionality when the full node page view is overridden.

alexpott’s picture

Re #11.

In addition to the "Treat this as the primary node page" you also need to disable the "no extras" option in the "Node content" pane. Then the menu_trails hook_nodeapi's view op will be triggered then everything seems to work as expected.

jcisio’s picture

#11 and #14 don't work if the content is cached. #7 works as expected.

pelicani’s picture

#7 rocks!!!
I hope y'all figure out the best way to do this.
thanks for the patch.

rapsli’s picture

Version: 6.x-1.1 » 6.x-1.x-dev
Status: Needs review » Needs work

I'm the author of power_menu (http://drupal.org/project/power_menu), which is actually doing the same thing as menu trails, with a different UI, that makes the menu the essential part for structering a website. Well obviously I had the same problems and since I took some code of this module I can aswell give something back.

Well, hook_init is not very nice, I think this one here is doing a better and cleaner job:

/**
 * implementation of hook_ctools_render_alter
 * 
 * When we use CTools Pagemanager, hook_nodeapi (view) is not being called, because ctools alters the
 * hook_menu and redirects the page callback to it's own function in node_view.inc Well, power_menu
 * never knows that a node is actually being displayed -> so we alter the ctools_render function and
 * start the normal power_menu_nodeapi procedure
 * 
 * @param array $info
 * @param boolean $page
 * @param array $args
 * @param array $contexts
 * @param array $task
 * @param unknown_type $subtask
 */
function power_menu_ctools_render_alter($info, $page, $args, $contexts, $task, $subtask)  {
  if ($task['admin path'] == 'node/%node' && $page) {
    power_menu_nodeapi($contexts['argument_nid_1']->data, 'view', NULL, $page);
  }
}
fuerst’s picture

Version: 6.x-1.x-dev » 6.x-1.1
Status: Needs work » Needs review
FileSize
1.05 KB

Thanks a lot! Works well for me, patch for 6.x-1.1 attached.

ayalon’s picture

Version: 6.x-1.x-dev » 6.x-1.1
Status: Needs work » Reviewed & tested by the community

I tested patch #18 and this is the best solution and works perfectly.

Should be commited immediately, because we had enough votes and tests.

sun’s picture

Status: Reviewed & tested by the community » Needs review

Thanks, looks better!

However, we need to adhere to http://drupal.org/coding-standards and http://drupal.org/node/1354

Also:

- The PHPDocBlock description of the hook implementation reads a bit too colloquial; we can shorten that.

- We can remove the @param directives.

- Any comment line should wrap at 80 chars.

fuerst’s picture

FileSize
737 bytes

Corrected patch attached. Coder module did not find anything now.

fuerst’s picture

Status: Needs review » Reviewed & tested by the community
fuerst’s picture

Status: Reviewed & tested by the community » Needs review

Sorry, wrong status assigned in #22

dreamdust’s picture

Status: Needs review » Reviewed & tested by the community

#21 works perfect!

davidwhthomas’s picture

Thanks, was having the same issue, patch #21 fixed it.

ndm’s picture

Thanks, patch #21 works exactly as i want

Peter Törnstrand’s picture

#21 is not working for me but #7 does. I'm not sure why though, #21 should work. It seems the call to menutrails_nodeapi is done with the exact same parameters in hook_ctools_render_alter and menutrails_init.

Is this because I'm using Panels Everywhere?

kriskhaira’s picture

Thanks, #21 works for me on Drupal 6.19, Panels 6.x-3.7 & Menu Trails 6.x-1.1.

mikeytown2’s picture

Just a heads up; I'm now using the same hook in boost as the patch here is proposing.
http://drupal.org/node/453908#comment-3415970
The hook gets passed 1 more variable though; $handler is missing from the patch in #21.

hook_ctools_render_alter($info, $page, $args, $contexts, $task, $subtask, $handler) { }
fuerst’s picture

The $handler parameter is new since Revision 1.23.2.4 of ctools/includes/context-task-handler.inc. At least for the patch in #21 it is not important to call hook_ctools_render_alter() without it. Would be good to add it to be API-safe of course.

jaydub’s picture

#21 works as advertised, hopefully can be added to a release soon.

anon’s picture

Status: Reviewed & tested by the community » Active

I cant get this to work.

Im using the "node_view" panel page as my node panel.
My node includes some terms, and I have assigned the terms to the menui tems with "menu trails".

But the meny doesnt apper in the panel.

If I show the first menu level, its ok, but I need to only show the secound and down.

EDIT:
The patch works if we assign the nodes to the meny with a menypost directly.

cray146’s picture

subscribing

hefox’s picture

Status: Active » Reviewed & tested by the community

Active suggests there is no patch to review. It's not clear that the patch was anon's issue so setting it back to RTBC. However, if the patch is bugged, set it needs work, not active.

I personally dislike calling menutrails_nodeapi like that; my preference would be to add a wrapper function with what menutrails_nodeapi does. and have each call that instead. However, I have nothing to do with this issue, just stumbled on it while helping someone in #drupal IRC.

Oh, add a new line after the end so don't see "No new line"

davidwhthomas’s picture

I found the patch worked but for some reason was removing the node title, only for anon users.

I fixed with an adjustment to the patch to set the title again.

Putting here in case of use to someone else.

<?php
/**
 * Implementation of hook_ctools_render_alter().
 *
 * When using Panels module (CTools Pagemanager), hook_nodeapi (view) is not
 * being called. Use hook_ctools_render_alter() to start the
 * menutrails_nodeapi procedure.
 *
 * @see http://drupal.org/node/362065
 */
function menutrails_ctools_render_alter($info, $page, $args, $contexts, $task, $subtask) {
  if ($task['admin path'] == 'node/%node' && $page) {
    // Set title from node title as is unset for some reason..
    drupal_set_title($contexts['argument_nid_1']->title);
    // Activate menutrails
    menutrails_nodeapi($contexts['argument_nid_1']->data, 'view', NULL, $page);
  }
}
?>

DT

plan9’s picture

I'm trying to get this to work on a 5.x install. I think the patch at #7 could work but menutrails_nodeapi($node, 'view', NULL, TRUE); probably needs to be tweaked for compatibility with 5.x branch.

Anyone know how this should be changed?

Hanno’s picture

#21 worked for me, subscribe

Exploratus’s picture

#21 worked

kiwad’s picture

Patch in #21 works well.

Could not reproduce "removing the node title, only for anon users" from #35

shawngo’s picture

Patch #21 worked great!

FiNeX’s picture

Patch #21 works fine even with menu_blocks and i18n. Thanks!

dbassendine’s picture

Patch #21 works well for me using Panelizer and Menu Trails

dbassendine’s picture

Quick note: I can't reproduce the missing title for anon users.