Submenu Tree Doesn't seem to allow View menu items in any mode other than Menu

dubitable - November 12, 2008 - 02:57
Project:Submenu Tree
Version:6.x-1.3
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:by design
Description

So, I was experiencing some weirdness after I added menu items which pointed to Views (with a Page display, to be precise)--the Views weren't showing up in the node which had Submenu Tree turned on, except in "Menu mode." So I checked through the code in submenutree.module and saw this line (346, in the _submenutree_menutree_view() function):

      if ($v['link']['hidden'] == false && $v['link']['page_callback'] == 'node_page_view') {

I changed it to this:

      if ($v['link']['hidden'] == false && ($v['link']['page_callback'] == 'node_page_view' | $v['link']['page_callback'] == 'views_page')) {

And now it seems to work (and if you look at the 'if' block enclosing that code, you can see why View items show up in "Menu mode" but not otherwise). Perhaps there is a better, even more general way to do this? I dunno, I'm not a Drupal guru, just another hacker. If this is good enough, then great: I've attached a patch. Otherwise consider this merely a post pointing out an issue that needs resolution.

Thanks for the great module by the way, it solved a problem for me nicely. I'm working on a semi-big deal site now that uses it, and I'll let you know when I'm done about including a mention if my client is cool with it.

DD

AttachmentSize
submenutree-view_fix.patch760 bytes

#1

dubitable - November 12, 2008 - 03:33

Why did I use a bitwise or (|) instead of logical or (||)? I guess I'm tired. Revised patch attached.

Also, I'm realizing this has other implications, as the items array is passed with a node attached. Hmm.

I'll keep looking at it and propose another patch if it makes sense...

Further edit. The more I investigate the implications of this, the more I'm unsure if it is a worthwhile patch. However, I'll leave it here for your consideration. It would require some significant changes to the theme functions in the module as well, I believe, and I'm not sure how appropriate that would be. I can use what I've changed by manipulating items in template.php of my theme, but it may not have general utility for other people out there.

ANYWAYS, if nothing else, perhaps I could request that you mention how the module treats Views in the README, or as a small note in the module interface itself when choosing between "Menu mode" and other modes...

AttachmentSize
submenutree-view_fix.patch 761 bytes

#2

bengtan - November 12, 2008 - 08:58

Hmmm..... I can see what you're trying to do.

The behaviour is actually by design - submenutree is only supposed to work in a menu tree with only nodes.

Most of the viewing options (teaser, fulltext etc) only make sense with nodes. It's just by coincidence that you've chosen menu display, and that works for your site because submenutree is directly calling into the Drupal menu system.

While it'll be nice to have submenutree work with any sort of menu items, it's problematic because submenutree doesn't know how to compute a menu item's title, teaser, fulltext etc. unless that item is a node.

So... undecided how to treat this.

One possible solution is to make submenutree work for any sort of menu items, but only when displaying as menu.

The disadvantage here is that it will then confuse people, because the behaviour will differ depending on the choice of display option.

#3

dubitable - November 18, 2008 - 16:45
Status:needs review» by design

While it'll be nice to have submenutree work with any sort of menu items, it's problematic because submenutree doesn't know how to compute a menu item's title, teaser, fulltext etc. unless that item is a node.

Yeah, I realized after the fact everything you just laid out...what I'm trying to do just doesn't quite make sense after consideration. Now, if I could arbitrarily attach content to Views (like make CCK fields part of Views outside of the Views query, if you see what I mean...but that doesn't really make sense...) then this may be a viable option. But now it isn't really a useful patch.

What I've done is the inverse: use the CCK Views Reference field in a node, and then put that node in the menu, so that your module can pull teaser items from it. Voila.

So... undecided how to treat this.

My suggestion: make a small note of it in the module documentation, and be done with it. ;)

Thanks for your considerate response!

Small edit:

One possible solution is to make submenutree work for any sort of menu items, but only when displaying as menu.

I believe it does so currently?

#4

bengtan - November 19, 2008 - 00:55

> use the CCK Views Reference field in a node, and then put that node in the menu, so that your module can pull teaser items from it.

Good trick.

> I believe it does so currently?

Yes, you are correct. I think I got my thoughts messed up in the previous comment.

Have a good day.

#5

wojtha - January 18, 2009 - 13:48
Category:bug report» feature request

Hi,

I fall in similar issue like dubitable. I'm currently working on a module which allows creating multiple menu links per one node. (It's currently in sandbox but I hope to release it soon.)

My new module allows that nodes can appear on different places at the website and has different breadcrumbs and active menu trails. I know that Menu API doesn't support this "by design", because duplicate content makes lower pagerank. BUT I read some article from Google about it and it can be easy sanitized with marking duplicate node pages with "robots noindex" metatag...

To use the existing Drupal Menu SystemI (and not to create my own menu system...) I create paths like "node/25/pid/something_unique" and then I use simple page callback which handle this type of paths to get appropriate content and breadcrumb.

Now I'm thinking how our modules can cooperate, because I create it from similar reason and inspired with your module - to sort and create website structure driven only by Drupal Menu System. As dubitable found, you have hardcoded support only for ordinary nodes... I don't like redirection way of handling this kind of things ... it seems to me more like a workaround than a solution. The solution which seems good to me is: Is it possible to implement an API callback when you building a submenutree content from tree of menu links?

So every module which implement your hook can add or launch its handling function.... it seems like really easy way to make your module much flexible and powerful!

I can try to make some experiments and make a patch.

bengtan what's your opinion about that?

#6

bengtan - January 19, 2009 - 02:26
Category:feature request» bug report

Hi Wojtha,

Firstly, I would prefer that you post this as a separate issue, because it's different from the original poster's issue.

In general, I'm open to patches and feature proposals as long as they do not result in too much extra work for myself.

Specifically to your situation, submenutree.module uses the hook_nodeapi() hook to insert/generate the submenutree blocks. If your module uses node_load() and node_view() to display nodes, then hopefully, it should 'just work'. However, perhaps I have misunderstood what you are trying to say, so please correct me if I am wrong.

(Please do not continue this discussion here, please post a separate issue. Thanks.)

 
 

Drupal is a registered trademark of Dries Buytaert.