Posted by smithn.nc on January 21, 2009 at 3:12pm
| Project: | Menu Trails |
| Version: | 6.x-1.1 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | reviewed & tested by the community |
Issue Summary
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?
Comments
#1
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.
#2
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
#3
well panels2 is really broken and is being overhauled for panels 3. so i'd argue against adding any special case code for it.
#4
Nodes overwritten by Panels node_view still have the
node/<nid>URL internally. You can get the$nodeobject by callingnode_load()usingarg(1)for the nid.The attached patch modifies Menu Trails by loading the $node object in
menutrails_init()and callingmenutrails_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.
#5
subscribing
#6
I have tested this patch and it corrects the bug on my system.
#7
Just a small glitch in the patch though (deprecated by-reference parameter). Here is a fixed one.
#8
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.
#9
Patch applies well for 6.x-1.x-dev and works with Panels 3.x.
#10
Patch #7 worked well for me too - good work!
#11
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.
#12
That's good to know.
You may also use the modul menu_breadcrumb which does not depend on invocation of
hook_nodeapibecause it useshook_initto 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.#13
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.
#14
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.
#15
#11 and #14 don't work if the content is cached. #7 works as expected.
#16
#7 rocks!!!
I hope y'all figure out the best way to do this.
thanks for the patch.
#17
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:
<?php/**
* 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);
}
}
?>
#18
Thanks a lot! Works well for me, patch for 6.x-1.1 attached.
#19
I tested patch #18 and this is the best solution and works perfectly.
Should be commited immediately, because we had enough votes and tests.
#20
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.
#21
Corrected patch attached. Coder module did not find anything now.
#22
#23
Sorry, wrong status assigned in #22
#24
#21 works perfect!
#25
Thanks, was having the same issue, patch #21 fixed it.
#26
Thanks, patch #21 works exactly as i want
#27
#21 is not working for me but #7 does. I'm not sure why though, #21 should work. It seems the call to
menutrails_nodeapiis done with the exact same parameters inhook_ctools_render_alterandmenutrails_init.Is this because I'm using Panels Everywhere?
#28
Thanks, #21 works for me on Drupal 6.19, Panels 6.x-3.7 & Menu Trails 6.x-1.1.
#29
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;
$handleris missing from the patch in #21.<?phphook_ctools_render_alter($info, $page, $args, $contexts, $task, $subtask, $handler) { }
?>
#30
The
$handlerparameter 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 callhook_ctools_render_alter()without it. Would be good to add it to be API-safe of course.#31
#21 works as advertised, hopefully can be added to a release soon.
#32
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.
#33
subscribing
#34
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"
#35
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 <a href="http://drupal.org/node/362065
" title="http://drupal.org/node/362065
" rel="nofollow">http://drupal.org/node/362065
</a> */
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
#36
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?
#37
#21 worked for me, subscribe
#38
#21 worked
#39
Patch in #21 works well.
Could not reproduce "removing the node title, only for anon users" from #35
#40
Patch #21 worked great!
#41
Patch #21 works fine even with menu_blocks and i18n. Thanks!
#42
Patch #21 works well for me using Panelizer and Menu Trails
#43
Quick note: I can't reproduce the missing title for anon users.