I'd really love the ability to add an argument or something to a view that would add menu items linked to the nodes returned by the view as children of the view's page's menu item. Here's an example of why I'd want to do that. I've created a content type which I use on nearly all of my sites called "issue" that allows campaigns to post issue position statements. I then created a view which simply lists the issues straight out either as teasers or a list of titles. I also have a menu item for that view, which I usually call "On the Issues". Currently, if I want the issues to appear as children of that menu item, as I did on www.murtha.org, I have to menually set the menu item for each of those nodes. It'd save me a considerable amount of time if those appeared automatically as children of the view's menu item without me havng to create them and put them there.
Comments
Comment #1
adsilcott commentedSeconded!
Comment #2
merlinofchaos commentedWhat you ask for could be done in an external module, but Views itself is unlikely to offer this kind of thing as a feature. It's fairly expensive and has some serious complications and a fairly narrow audience.
Comment #3
earthcub commentedI wouldn't mind taking a stab at creating an external module to do this as I'm looking for the exact same thing. Can you offer any advice how to go about it? i.e. Where would I look for an example of the code path to follow or where could I start?
TIA
Comment #4
konsumer commentedI'll give it a shot too. It's a race!
Comment #5
merlinofchaos commentedCertainly.
The best place to start is with the function 'views_build_view'. Your code can take a view (presumably one that must be set by the user) and use the 'items' or 'result' option in order to get a list of nodes (rather than a themed display).
One can then use this list of information to style a menu.
You'll need to ensure that either node.title appears in the view, OR that you have some other field to use as the menu text. Either one will work; the latter is more complicated since you have to figure out how to use it. It's much easier to examine the view object and ensure that the node title field exists.
(The easiest way to do this is to do a dump of the $view object, after load, examine the fields, and see what fields you need to check. In the fields array you can check tablename + field and they should be 'node' and 'title' respectively).
Comment #6
jonbowyer commentedDid anyone get anywhere with this??
I'm trying to build a hierarchical site structure based on content types and taxonomy terms.
I'm trying to build a structure something like:
Vegetables
Meat
All Recipes
(Note: my site has nothing to do with food, this is just a simpler illustration of the sort of thing I'm trying to do.)
The key point here is that this is a hierarchical structure, but one in which there is some repetition of the same items ("Winter Veg Soup" appears under Vegetables - > Recipes, and also under "All Recipes").
My intention here is therefore (with the above example) to make a "Recipe" content type, and a "Section" taxonomy vocabulary (with terms "Vegetables" and "Meat"). This therefore enables "Winter Veg Soup" to be created as a content item of type "Recipe" (so it appears under "All Recipes") but also be tagged as "Vegetable" (so it also appears under Vegetables -> Recipes). Meanwhile "Pork" can be created as an ordinary Story item, and be tagged as "Meat" so it appears directly under the "Meat" section.
I'm fairly sure views can let me create pages which pull out the relevant content, and can also add links to the view for "Vegetables", "Meat" and "All Recipes" BUT it does NOT appear to enable the automatic creation of child menu items within each of these (i.e. the links to the content items that are pulled out by that view), so I can not get my sidebar menu to generate the tree shown above.
If anyone could point me towards some working code / modules for doing this that would be great.
As far as I can see the only solution may be to abandon the views approach and look instead at using the category module, so that I can use the category menu module to automatically generate my menu tree. Apparently these are buggy though, so I don't really want to use them for the professional website I am working on.
The only other possibility I have spotted is perhaps to use taxonomy menu, but I don't think this will really work for me either because my structure is more complicated than just a single tree (due to the fact that "recipe" items appear in more than one place).
If anyone has gotten a way to do this with the views module, please let me know.
Jon
Comment #7
basicmagic.net commentedsubscribe
Comment #8
asimmonds commentedReverting title
Comment #9
Mike Sances commentedsubscribe/bump
Comment #10
just_an_old_punk commentedI must be missing something obvious but there is no reference on this page of "what" we should subscribe to... A mailing list? IRC channel? Some drupal.org thing? If people have stated this is an issue external to the Views module (to which I have no objection, so long as there is a solution that works), then we shouldn't expect to be subscribing to something related to the Views project, or should we?
Curiously confused,
Comment #11
Mike Sances commented*Nothing in this comment relates to the original issue*
posting a comment to a thread puts it into your tracker at www.drupal.org/tracker/Your User ID. therefore site visitors post a comment with the word subscribe. at least that's the assumption I've been posting this all over the place under.
AFAIK there is no e-mail update or RSS feed for your tracker, which is probably why you see "subscribing" comments so much.
Comment #12
masood_mj commentedSubscribe
Comment #13
merlinofchaos commentedPutting the version back. Sigh.
Comment #14
raimondious commentedHas anyone worked on any of the proposed modules above or found a module that does the same?
With no experience with module writing at all, I'd think this would be about as expensive as a view block. merlin, you said Could you expand on that a little? What are the serious complications?
I think Views is frequently used to create dynamic collections of related nodes. Wouldn't the ability to add the nodes into a normal menu be useful for this common case? The reason I came here is because I want to create an archive of "news" nodes and place it within my menu without requiring the user to put the article into the correct menu each time they create one. I've heard the "make a block and put it in the right region" solution a few times, but that's a work-around and doesn't actually do what I want -- I want the view to be integrated into the menu hierarchy, not just tacked on.
Comment #15
mitchell commentedAs merlin said, this will have to be another module. Sorry to crowd the issue queue, but postponed seems like an alright status for this.
Comment #16
mcfilms commentedOkay, it can't be integrated into views. But there are almost a dozen people here interested in this. Is there a place to follow up? Did eathcub or konsumer make any progress to this end? I'll place $100 bounty on a module that would provide the drop-down menu from the view results. Anyone up for it?
Comment #17
mitchell commentedComment #18
robbertnl commentedsubscribing
Comment #19
netbear commentedHierarchical structure is often needed in many sites and what now views provides is page view with arguments, which allowes to create such structure but when we go to the node page we go out from that structure and have no way back such as menu to show it. I think it would be nice feature very helpful for many projects.
I see it as checkbox on the view setting page which says "Create the menu, accompaning this view?".
What do you think about such possibility?
Comment #20
mitchell commented@netbear: It seems like you're describing a display type.
So a view would appear in the admin/build/menu (instead of admin/build/blocks), and its results would be menu items.
Comment #21
Christopher Herberte commentedsubscribe
Comment #22
anrikun commentedsubscribing
Comment #23
merlinofchaos commentedThis will not be added to Views itself due to the complexity of keeping it properly updated. It would have to be its own module.
Comment #24
SuperMidget commentedPerhaps you could use hook_form_alter so that it will automatically add the node to a certain menu.
Then you are not using views to define the menu, but at least you don't have to click the menu settings.
Comment #25
mitchell commentedReclassifying
Comment #26
jonbowyer commentedI'd just like to draw attention back to comment #6 above (the one I made back in Dec 2007).. and the last paragraph of raimondious' comment (#14) made a year later..
What we were both talking about is the ability to embed views results *within* a menu hierarchy, not having them generated as a separate menu.
In other words we want to be able to specify a "parent" menu item under which the views results would appear as child items.
Mitchell's comment (#20) misses that key point by suggesting that the view would generate a separate menu, in which case there is little advantage over simply using a views block that looks like a menu, which is already supported.
I suspect things may have moved on a bit since I made my post in 2007, but a quick look at the category module suggests it still isn't in a state which can be deployed on a professional website. If anyone has any other suggestions or comments on achieving the functionality I mentioned in comment #6 I would still be interested. I still consider this to be an important feature with widespread applications, and one that really should be achievable within Drupal without having to resort to unstable or beta modules. If I am out of date and there is now an elegant solution, do let me know.
Cheers,
Jon
Comment #27
jonbowyer commentedReclassifying as feature request, as per previous comment.
Comment #28
kwixson commentedI second this as a feature request. I have a non-profit with programs, each of which has a tag "program" and there is a view for showing Page type nodes with the tag "program" in a grid, and a menu item linking to the view called "Programs". I would like there to be a sub-menu item for each of the items on the page for the view (i.e., each page node with the tag "program") under the "Programs" menu item.
Comment #29
Draupnir commentedSubscribe.
Comment #30
julou commentedSubscribe to #26…
This sounds like a long overdue :)
Comment #31
merlinofchaos commentedAt the risk of repeating myself:
Re-opening the issue without even providing an argument is frustrating, at best and rude at worst.
Comment #32
Shai commentedI'm also interested in this.
I'm not changing the status back to active. merlinofchaos has been absolutely clear that he won't add it and I respect that.
The question is, where is the right place for this discussion to take place? Anyone have a clue as to whether any other modules touch this issue or other ideas to move this forward... while NOT changing this issue to "active."
Shai
Comment #33
julou commentedI started a new issue as a support request about the best way to do this: #552284: Is this the right way to create a "menu view" module?
Please give your feedback!
Comment #34
brisath commentedSubscribing!
Comment #35
graper commentedI wanted to put in my 2 cents and ask if this module http://drupal.org/project/taxonomy_menu wouldn't do the job that people are wanting?
The way I see it is that the taxo module does the hierarchy and views doesn't have the ability to make a hierarchical list, but could be altered with an add on module to do so.
The mentioned module seems to integrate into views so maybe it does what people are wanting and no one found the right thing.
edit
After reading back through the comments, I think I didn't see that what people want are the nodes linked in an existing menu and not just a hierarchical list of categories. It's never come into my mind to ever have that in my designs. If I needed a small list of links to specific articles like "Top 5 Issues" I would just create a block to house that so that the block can be themed to make those stand out.
as for the example of recipes, I'd like to say that it would be dangerous to have nodes linked in the menu, especially duplicate links. While it may show a good example of what is being talked about, the problem would be scalability; meaning when you have 1000's of nodes (recipes), the menu would take so much longer to process and take so much more time to send the html data to the browser that the site would just slow down as you reached higher and higher node counts. While I know it was just an example, and a good one, I just felt that the pitfalls need to be pointed out also to round out the discussion of a design like this.
Comment #36
dean.p commentedHi, yes I can understand if there are 1000's of nodes this may be problematic, however, I think the idea of this functionality is still valid if not practical ;)
In my case I would like to grab a bunch of nodes, grouped by Taxonomy term and displayed as a menu. I have managed to do this with a 'Staff' menu. (see http://www.harkness.co.nz/our-people ) The menu on the left are nodes grouped by Taxonomy term (Team), sorted by an another taxonomy term of another vocab (Role), then alphabetically by title and constructed as a menu.... There was much wailing and gnashing of teeth! I gave up on views and did my sql query and code right in the block template virtually manually constructing the menu although I did not manage to get menutrails to work probably because this is all done with custom code and not using the drupal menu api.
What I am thinking is, there must be a way to make a view, then edit the template (albeit custom coding again) to create an array that then gets passed through the Drupal menu api? Therefore, it should function as a standard menu with menutrails etc. I know nothing about building menus for Drupal so I don't know if there's problems with this theory? Anyway, this is the approach I'm going to use and see if it leads anywhere.
Any further insight would be greatly appreciated.
Comment #37
game commentedI think this is exactly what I was looking for... thanks graper! :-)
Comment #38
LaurenH commentedSubscribing.
Comment #39
kenorb commented+1
Comment #40
SeanBannister commentedsub
Comment #41
neorg commentedsubscribing
Comment #42
scottprive commentedYou can do this already in Views + Panels + Taxonomy + CCK.. but you build it.
My coworker Ben sketched this out and I'm following this process, works well, but I'm not sure I can explain it well in a quick post.
If you almost get what I am saying, you can work it out (but if not, sorry... this technique needs a multi-page tutorial/article).
Each document you want "auto-menu" on, you have a pair of extra CCK fields.
One field is the URI for the content in question (no slashes), example: "about-us".
This first field can either be a Textfield or Taxonomy, depending on what level of control you want to give content editors (Taxonomy can be pre-populated with terms by the admin, or you can let content editors invent new terms and therefore new menu links).
The SECOND field is optional, a text field or taxonomy field representing a "short title" for the document (because after all, the Title field might be too long to insert as a hyperlink text in a menu).
Now you use Views to build the menu. Select all the terms in a vocab plus all the 'short names', then use a Views template to theme this very plain "list" into your menu (wrap it in similar HTML as your site uses for the Drupal maintained menus, so the styles match). Get this working first before continuing.
Now the tricky part.. you might ask, how does views "know" what menu to build or how to get the URL arguments into views?
Use Panels.
Remember the Vocabulary name and terms that represented the menu structure, from the document?
Well, Panels can get that from the URI (ex: Panel uses arguments like /support/!subsection or /support/!subsection/!nid)
Once Panels gets that little bit of URI variable, Panels can get additional context (such as the vocab ID or term ID or other node attributes).
Add your Views as content to the Panel, and pass those other contexts to views.
So for example, my support vocab has a term "faq" whose TID is 238.
Panels gets "faq" from the current URI, gets the TID context from panels, and passes the TID to Views.
Now the View displays FAQ-related content (this was worked out in the view above).
NOTE: For some reason, passing term name or vocab name from panels to views did not work for us (ie, passing "faq" in Views works in views itself, but not when it got the argument from Panels. Not sure why, but using the numerical ID representing something worked fine).
In some cases, we couldn't in Views lookup some taxonomy queries and cross reference against Node IDs.. probably because in Drupal 6, taxonomy is not normally a full node. In these cases we created in CCK some dummy navigation pages, where the pages contained 2 or 3 CCK fields (each matching the same stuff we put into taxonomy). This got around the taxonomy query issue from views.
The point being of all this is that content editors can edit documents to create new menu links, new menu link titles, and if they remove a node the menu link is removed with it, and you can stop creating manual links in the body of a node (since these links are never maintained in Drupal.. rename a node or change it's ID, and the manual link you created is broken). This takes some of the site structure burden off the admin user.
Once we get to some work milestones, I'll see if I can help my coworker polish up our internal documents and create some kind of web tutorial. Reviewing what I just wrote, most won't get what I am saying unless they are already well familiar with views and panels, and just needed a nudge to consider this is how you could do it. (In other words, sorry if you get stuck trying to follow this... it's a complicated task and not easily covered in a simple message post)
Comment #43
SeanBannister commented@tzoscott: Thanks for the tutorial, I didn't get it all but understand the gist of it. However the advantage of creating a "real" menu is modules like dhtml_menu can work with it, which my particular use case requires.
Comment #44
steven jones commentedSubscribe
Comment #45
sparkymark commentedSomeone wrote this on a different website, but I tried it and it didn't work. The first section works, creating the links, but when I click on the links, I get the "page not found" error:
""
By default, views of type Term link to category pages (taxonomy/term/[tid]). I find that category pages are more useful as custom views where you can control fields. You can effectively replace the default category pages with a customized view by following this views recipe. And no programming is needed.
First create the categories block
1. Create a new view of type "Term"
2. Add a block display
3. Set row style to fields
4. Add Taxonomy: Term ID as a field (this must be first). Be sure to set "Exclude from display". This information will be used to as an argument in our other view.
5. Add Taxonomy: Term as a field. Check "Output this field as a link" and set the link path to your-other-view-path/[tid] You will only have the token for Term ID available if the Term ID field is listed above the current field.
6. Create a new view of type "Node"
7. Add a page display
8. Set the path to the same path used in step 5. ( your-other-view-path )
9. Add a Taxonomy: Term ID argument
10. Customize the rest of the view to your liking
Now, term listings will link to your custom view instead of the default category listing page. Because your custom view takes an argument, you will restrict the view to listing the very same nodes that the default category listing will show. However, you now have the power of views to customize the display.
""
I would really appreciate someone explaining this last stage in more detail.
Comment #46
steven jones commentedI'm working on this over on github: http://github.com/computerminds/views_build_menu
Comment #47
taote commentedHi Steven, I'm very interested on this. I installed the module, created a view a defined the item menu, but it's not showing on the menu.
What is the state of the module?
Thanks!
Comment #48
steven jones commentedYeah, I basically had 45 minutes on a train, and so the module is far from working.
So the status is: 'In progress'. I would suggest that if you can code then you pitch in and help out, otherwise wait a couple of weeks, when it'll need testing and then help in that regard will be very welcome.
Comment #49
taote commentedOk, I don't have any experience on module programming yet. It seems the function theme_views_build_menu_row it's not being called. If there is anything I can do to help, testing for example, I'll do it. Keep us informed, please. And thank you.
Comment #50
steven jones commentedI should have some time to work on this week, so probably check back at the end of the week, or just 'watch' the repo on github.
Comment #51
mattiasj commentedinteresting, will try this out.
Comment #52
steven jones commentedThis now has its own project, so I'm stealing this issue...
Comment #53
mcfilms commentedBest news all day! Need something tested? Do you have a Drupal CVS account?
Comment #54
Flying Drupalist commentedYay you're a hero.
Comment #55
kla2t commentedsubscribe
Comment #56
LiveWire commentedsubscribe
Comment #57
Anonymous (not verified) commentedsubscribe
Comment #58
graper commentedOk so I see that this thread has been swiped. While this new module bring the functionality to views which can be extended to have parameters like taxo_id and such, I just want to give some information that a simple menu can already be created by the Menu Module, which can build a hierarchy, and just requires that the menu placement is also entered at the time of node creation. The only difference is that the Menu Module is not as Dynamic as the views module.
I just want to help the community by letting them they don't have to use a bazooka like the Views module to create a simple menu when the default menu module is quite capable.
Granville
Comment #59
steven jones commentedSure, you can create simple menus without using views and this module to do so, but those people probably won't ever stumble upon this issue.
Is there another use case I'm missing?
Comment #60
steven jones commentedMarking this fixed, as the module is now working nicely.
If someone wants to change the scope of this issue from getting views to create Drupal menu items, feel free to do so and re-open (and move out of this queue to the correct place).
Comment #61
mcfilms commentedI am only adding on to this issue in case Steve or others were not aware of this.
The latest version of Views and the CTools module enable an (as far as I know) undocumented ability to create a drop down "Jump" menu from within views. You can place such a menu in any block. See http://drupal.org/node/794992#comment-3281264
I have not tried Views Build Menu yet. But from what I read, it is designed to integrate into the Drupal menu system and may even support hierarchical links. That being the case, it is a far more robust solution and I support further development. Well at least verbally if not financially.
Comment #63
rikki_iki commentedIs there any way this module can work without the need for periodic views execution? I want the menu items to be able to change instantly to meet an argument.
Comment #64
pelach commentedsubscribing
Comment #65
Anonymous (not verified) commentedThen you should not use the Drupal menu system at all - it will not be possible. The menu system is cached in core.
Why don't you just create a Views' HTML list and style it like a menu? You could theme the .tpl files to add certain menu classes. That's all you need and is really easy to do.
Comment #66
hedel commentedIs a old thread but for anybody who come here finding information...
Is possible use views in one menu with the follow modules: