Closed (won't fix)
Project:
Views (for Drupal 7)
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
7 Aug 2008 at 19:53 UTC
Updated:
2 Mar 2012 at 22:21 UTC
Hello,
I encountered the following bug/problem (if it's not a bug please feel free to assign a new category).
I've a menu with two levels. Level 1 links to a pageview and passes an argument to the view (e.g. /pageview/argument1). The argument is correctly handled in the pageview. But the second level of the navigation is not displayed. If I remove the argument in the menulink, the subitems are displayed correctly.
Many thanks in advance.
Comments
Comment #1
merlinofchaos commentedCan you be mor e explicit about your menu setup? What do you mean by second level?
Comment #2
merlinofchaos commentedComment #3
eigentor commentedI am having a similar problem: I created Views pages with arguments.
Now I created a nested menu as follows:
sales
-- sales news
-- sales team
accounting
-- accounting news
-- accounting team
The Views are: team, news and overview. The department (sales, accounting) are passed in as argument, so the paths are as follows: team/2 is sales team news/2 is sales news and overview/2 is sales.
Now when I navigate to sales, the Menus just won't open and display the nested menu level.
This works when using normal nodes as paths.
Does the menu system nod recognize views pages with arguments as normal paths?
Cause there appears to be some kind of logic in the menu system, so menus won't open if say you would link every menu entry insite to node/25.
Comment #4
eigentor commentedI investigated a bit further and the problem appears to be the following: A Views page does not seem to be able to be on a parent menu item that has children.
If a parent item links to a views pate, the menu just won't open and show the children. If it links to a node, all works fine. Weird. Is this a bug in my installation or normal behaviour?
Comment #5
eigentor commentedO.K. still one step further: Views pages with arguments are not recognized by the menu system as "real" paths.
Regular views that have a distinct path can, I was mistaken in #4
So a Views page with an argument - in the example above this would be overview/2 that links to the sales overview page - cannot be a menu parent, if you click the menu item, it just won't open and show the children menu items.
And if a child menu item is a Views page with an Argument, the menu collapses.
This is not very nice if you want to use Views pages with Arguments and still organize them in a regular menu structure.
Is there a workaround to make a Views page that is called by an argument being recognized by the menu system as a "real" Menu item?
Comment #6
eigentor commentedSolved.
Very simple:
What you have to do is enter the % sign as a wildcard for your Argument. I forgot that.
So the path looks like your-path/% and everything works fine.
Obviously the menu system needs this to recognize the argument paths as "real" paths.
Comment #7
ashtonium commentedOk, so just to review:
1. create a view with a page display and optional arguments
2. create a menu item to this view with an argument in the path (path/to/view/[argument1])
3. create another menu item to a view with an argument in the path (path/to/view/[argument2]), and set it as a child of the item created in step 2
Navigating to either "path/to/view/argument1" or "path/to/view/argument2" will display the view correctly, but the menu tree won't be expanded for the parent item created in step 2 above. The menu system sees the menu item as active, it just isn't expanding it.
eigentor's solution of changing the page display's path setting from "path/to/view" to "path/to/view/%" makes the argument required and the path to the view without an argument no longer works.
This all used to work just fine in views-5.x-1.x, but understandably, a lot has changed since then.
Comment #8
merlinofchaos commentedViews doesn't control the menu expansion, core does. This is probably a core issue and it seems likely there is nothing I can do.
One workaround might be to make 2 page displays; one with the argument required and one without the argument. That way you can get the best of both worlds, perhaps.
Comment #9
ashtonium commentedThanks for the suggestion. Adding a duplicate page display with the argument required in the URL seems to work around the issue for now. The view works with and without an argument and the menu system is expanding the menu items again.
Comment #10
petrelharp commentedIt looks to me as if the problem is that $in_active_trail is not set properly for a view taking an argument whose path allows no arguments. $in_active_trail is used by menu_navigation_links (http://api.drupal.org/api/function/menu_navigation_links) to determine whether or not to expand the subtree below each item.
In my example, at least, suppose that there is a view that takes arguments whose path is 'view', and that my menu is structured like this:
view/arg
- y
- z
a
- b
- c
and the rest of the items (a-c) and (y,z) are "normal" links. Then (using theme developer), visiting pages (a), (b), or (c) shows that the menu link corresponding to (a) has $in_active_trail=TRUE, as it should be. If I visit (y) or (z), the menu link corresponding to (view/arg) has $in_active_trail=TRUE, as it also should be. However, if I visit (view/arg), then the menu link corresponding to (view/arg) has $in_active_trail=FALSE, and the submenu below (view/arg) fails to expand.
The value of $in_active_trail seems to be set by _menu_tree_data (http://api.drupal.org/api/function/_menu_tree_data), and depends on the value of $parents, set by
menu_tree_page_data (http://api.drupal.org/api/function/menu_tree_page_data). From looking at those things, I don't see what's going wrong... although I know nothing about databases, and do not have a php debugger installed to be able to get to the bottom of things (sorry). Hope this helps someone.
Changing the path to "view/%" fixes the problem, as noted above.
Comment #11
damien tournoud commentedI was able to reproduce that.
The core bug is #432328: _menu_translate() sets $item['href'] to the stored path of the router, not to $_GET['q']... but even with that solved, Views does some weird things with the breadcrumbs.
Take the following View of nodes:
- Title: "All nodes"
- An optional "Node: type" argument, overriding the title to "Nodes of type %1"
- A page display with a "per-node-type" path
Now consider the following Menu:
- "All the content of the website" (path: per-node-type)
- "Nodes of type story" (path: per-node-type/story)
- "Nodes of type page" (path: per-node-type/page)
Assuming the core bug above is fixed, the breadcrumb on per-node-type/page would be:
"Home" >> "All the content of the website" >> "All nodes"
instead of the expected:
"Home" >> "All the content of the website"
Comment #12
petrelharp commentedAnother thing to add to this: using optional arguments in Panels also causes this behaviour.
In panels, the syntax for optional arguments in the path is "!name". If the path for a panel page is
"/example/!name", then a menu link to "/example/node-name" will not expand. If the path for the panel page is "/example/%name", indicating a required argument, then the same menu link will expand its children.
Comment #13
cangeceiro commentedIm running into the same issue myself using panels as in #12. However I cannot change my path to % because i get an error "Paths with non optional placeholders cannot be used as normal menu items unless the selected argument handler provides a default argument to use for the menu item." and i cant seem to find where i would set a default argument.
Comment #14
merlinofchaos commented#13: It's not something you can set in the UI, it's how the argument plugin is coded. The only argument that provides a default like that, as of this time, is the user: uid argument, so the menu can default to the current user.
Comment #15
Letharion commentedHello!
I'm cleaning up the Views issue queue, and thus trying to close open support requests that have had no activity in the past 6 months or more. If this is still a relevant please reset the status to active, and the new bug squad will make an attempt at the problem.
Comment #16
inlikealion commentedI'm having the same issues with this.
I have views pages with path /products/% where the argument is a taxonomy term. I manually added menu items to the primary_links in the menu admin (though I'd love it to be done programmatically) so it looks like:
home
about
products
--product1
--product2
--etc…
Set primary and secondary links to primary_links in menu settings, but in any of my views (products/%) pages the menu's aren't expanded.
1. Is there still not a way to have views arguments programmatically added to the menu system?
2. Why won't menu expand on a views argument page?
Comment #17
merlinofchaos commentedUnfortunately, there's nothing Views can *do* about that. Views does not control menu rendering at all, and there's no additional cues we can give hook_menu to do what you want.
Comment #18
inlikealion commentedThanks, Earl. I appreciate the quick reply, and understand that Views is limited in what it can do here.
So, people are basically just manually adding items to menu's? /products% in views then add Product 1 (products/product-1) for each value of % in admin/build/menus?
Comment #19
caprenter commentedJust to let you know of a fix that worked for me.
Using the image module and it's inbuilt Gallery views, I had to change the path of the 'image_gallery' view (Gallery Page) to image/%/% (the path is normally image/tid/(number) ), and then the menu's I had set to expand, did so.
The site using this is here:
http://www.bees-ymca.org.uk/image
Cheers
Comment #20
yan commented#6 was what I was missing, thanks!
Comment #21
Cablestein commentedDon't know if this is still a bug or what...
Encountered this today (Mar 2, 2012) on current Drupal 6 and Views.
Post #6 works for me. Re-iterating his steps:
-edit the view
-go to the 'Page' display
-in 'Page Settings', 'Path' re-write your path to include a '/%' at the end.
My case:
The View path was 'products' at first, then I came across this menu problem. Changed the View path to 'products/%' and the menu expands as it should.
My menu is manually built too.