I'm trying to retrofit features into an existing site for deployment, and need to support up to 8 different menus with it. I'd also like to be able to do so without selecting individual links.
To me it looks like the uses cases for the current support for individual links in a single menu, vs. maintaining several entire menus in code are a bit different, so I'm not sure how best to proceed. It seems like there's two main options:
1. Extend the current support to allow for multiple menus (probably with a 'select all' checkbox). This could get very unweildy IMO.
2. Rename the current menu support to 'menu links', and add separate support for exporting an entire menu separately.
I've started work on #2 in a custom module, will post a patch here once I've resolved some niggles.
I also noticed there's currently doesn't seem to be support for reverting menus, plid/weight information etc., that opens up a fairly large can of worms unfortunately.
Either way, opening this to track status, and just in case there's some code around somewhere which supports this which I've not found yet.
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | 633804-19-custom-menus.patch | 11.72 KB | johnalbin |
| #18 | 633804_custom_menus.patch | 12.28 KB | yhahn |
| #9 | menu_features.module.txt | 3.31 KB | dawehner |
| #2 | menus.tar_.gz | 1.33 KB | dawehner |
| #1 | menus.module.txt | 2.15 KB | catch |
Comments
Comment #1
catchSince menu hierarchy and lots of other things depend on mlid, exporting hierarchies relying on that is a no go for features - works for my use-case but not safe across different sites or deployments. That at least partially explains why the current code avoids all of this.
That makes this altogether trickier, however posting what I have so far for reference.
Major todos:
Figure out if there's a viable workaround for plid - maybe trying to use link_path, which isn't guaranteed to be unique, but often is at least per-menu (similarly for replacing items).
Create custom menus if they don't exist.
Consider whether it's possible to also delete menu items that have been removed from the feature, I'm thinking not though.
I've posted this as a .module rather than a .patch since I'm not sure it can even live in features.module at all without dealing with at least the first two of the above, and it's also unlikely I'll have time to work on those.
Comment #2
dawehnerHere is a module, which is based on the above file. It added support to create the menus, too. But missed the second TODO.
Comment #3
rapsli commentedgoing to try it out...
Comment #4
rapsli commentedoky, I've tested this module. It seems to work just fine, but there's one tweak I had to make, but unfortunately I can't find it anymore. Would love to see this feature get into the module
Comment #5
q0rban commentedHmm.. interesting.
Comment #6
Anonymous (not verified) commentedfollowing
Comment #7
catchBy the way I got this working for hierarchy but forgot to post back here and don't need this any more at the moment. If you're interested in taking it further find me in irc and I'll try to dig it up.
Comment #8
rapsli commentedis nobody taking this further?
@catch: would be nice if you could post your running version here
Comment #9
dawehnerHere is the dev version of catch.
Sadly i forgot about this issue
Comment #10
rapsli commentedhow are we going to proceed here? Creating a new module for this :S ... I think it would be better suited in the features module itself.
Comment #11
rapsli commented... this did not work with my menu
Comment #12
rapsli commentednever mind, it actually did work ;) I didn't actually enable the menu_features on the target system. It should probably also have a dependency in the feature
Comment #13
jmseigneur commentedYes, the dependency with menu_features should be added. In addition I've successfully used the package attached to #2 but when I updated that package with the code in #9 only the Primary menu was imported. With the code in #2 all menus were imported including custom menus.
Comment #14
Nick Robillard commented#2 is successful for me. Menus export and import properly so far.
Comment #15
lelizondo commentedsubscribing
Comment #16
yhahn commentedOn my list.
Comment #17
yhahn commentedI took a look at this tonight and here's my plan for the patch:
The patch currently expects each menu to be exported as an entire unit. I would like to see support for exporting individual menu link instances so that different features can provide menu links into the same custom menu.
To accomplish this, I think we should use
menu_name:link_pathas the identifier for each exported menu link. This would disallow the export of two links using the same link path in the same menu but generally speaking this is a serious corner case and probably a bad IA decision for someone to make in the first place.To support parenting, I propose replacing the plid reference with a similar
menu_link:link_pathidentifier.We will need a separate component for menus themselves (
menu_customtable, we can usemenu_nameas the identifier).Given that there is existing (and severely lacking) "menu" integration in Features at the moment we'll want a way to eat existing exports, let any features using the current integration get their exportables up to date, and then deprecate the old stuff.
Will get going on this next.
Comment #18
yhahn commentedAs promised, here is the patch.
Comment #19
johnalbinI tried the patch in #18. The menu export seems to work fine. But menu links don't get exported at all; when you click a checkbox next to a menu item, you don't get that ajaxy-icon of it doing work like other feature exports, so the menu links don't appear in the generated module.
Looking at the patch, it seems that only the link path and link title are supposed to be exported. IMO, this must include the options as well. There are contrib modules that add attributes to menu links; menu_link_save() puts attributes in the "options" column of menu_links. And features should support those options as well.
Here's the patch re-rolled to apply to -dev instead of 1.0-beta8, since I couldn't get the above patch to apply to -dev.
Comment #20
johnalbinAlso, individually clicking on each menu link when you want to export all the links in a menu is OMG awful. Perhaps add a checkbox for "all links" in a menu?
Comment #21
yhahn commentedThanks for rerolling.
I'm guessing when you applied #18 you didn't have this commit? http://drupal.org/cvs?commit=386952. I ran into this as well and it was because the form API key for these elements included characters that conflicted with the AHAH js handling (they were being confused for some jQuery selector syntactical elements). The commit above fixes this by encoding and then decoding such characters.
The patch does indeed handle the
optionskey as well as nearly all the other columns in themenu_linkstable except forplidwhich it makes portable by converting to the link path of the parent and relinking on install.I've now committed the patch here: http://drupal.org/cvs?commit=395030. Let's deal with adjustments and other issues in separate tickets.
Comment #22
kalis1subscribing