Title says it all. The fact that *nobody* has asked for this thus far, is indicative of how many people actually use this, though. But I need it for the demo at http://wimleers.com/demo/hierarchical-select/menu, so…

Comments

wim leers’s picture

Status: Active » Fixed

Fortunately, the API hasn't changed at all, so this was very easy :) The patch is only a few lines long!

http://drupalcode.org/project/hierarchical_select.git/commit/b60a84d

rv0’s picture

yay!

rv0’s picture

Status: Fixed » Needs work
StatusFileSize
new1.01 KB

Seems this is not completely ok yet:

1) had to change the weight of the module, otherwise $form['menu'] wasn't even available yet (this might be an issue on my site)

2) when editing menu items on admin structure, the HS works fine, but every time I choose something I get "An illegal choice has been detected. Please contact the site administrator." error messages displayed right above the HS. This happens for every parent item, no matter how deep.

3) HS Menu on node/edit pages seems totally broken. It checks for $form['menu']['parent'] which seems like a complete copy paste from D6 code.
I have attached a patch to fix this.

RE:

The fact that *nobody* has asked for this thus far, is indicative of how many people actually use this

Actually I think a lot of people (like myself) read the notice that you will continue on this in October... It would be rude to create an issue for it when it's clearly noted, meanwhile people are being patient or use workarounds/alternatives/custom code to get it done.

rv0’s picture

StatusFileSize
new1.01 KB

4) hierarchical select gives access to all menu's.. it should only give access to the menu's enabled for the content type

next patch fixes problem 2) as described in #3 and also includes the fixes from the patch in #3
I'll check if I find a way to fix 4)

rv0’s picture

StatusFileSize
new1.47 KB

grr ignore the one in #4

rerolled:

rv0’s picture

Status: Needs work » Needs review
StatusFileSize
new3.53 KB

think I nailed problem 4) as mentioned in #4

Basicly:
- in hierarchical_select.module, form_hierarchical_select_process(), if we have a content type, it is added to $config['params'].
- in hs_menu.module, hs_menu_hierarchical_select_root_level(), I check if there is a type in $params, if there is, I only show the menu's that are available to that type.

Everything seems to work perfectly now.
It's the cleanest solution I could come up with, considering my limited knowledge of this module. I hope I took the right approach.

patch also includes other patches from this page, and with this the module becomes usable for my project :D

rv0’s picture

StatusFileSize
new7.87 KB

In my usecase, I did not need HS on every node type, so it needed to be selectable.
- added a config setting on the HS admin page in hs_menu_admin_settings()
- added a check in hs_menu_form_alter()

The following patch includes this new feature + the previous fixes + code reformatting as I think I mixed spaces and tabs previously ;)

rv0’s picture

StatusFileSize
new7.87 KB

patch from #7 had incorrect default value for the checkboxes on HS menu admin page

rerolled:

rv0’s picture

Priority: Major » Critical

Just found another bug, this one is rather critical as it totally ruins your menu structure..
After changing a menu item (from admin/structure/menu/item/%/edit) the item is gone and so is the subtree.
the menu name got changed to "Array" in the database, for the item+ first children of the item.

Just spent an hour researching this issue and rebuilding my menu (I know _ backups_ *sigh* ) so bumping this to critical

rv0’s picture

Version: 7.x-3.0-alpha3 » 7.x-3.0-alpha4
Component: Code » Code - Menu
Status: Needs review » Needs work

just a quick update for anyone reading along:
- fixed some bugs related to how classes are appended to the html
- added enable/install/uninstall hooks, set the weight of hs_menu to 1

still trying to fix the bug in #9, patch will follow
the bug is also there on node creation, so currently hs_menu does not work at all.

rv0’s picture

StatusFileSize
new11.43 KB

the latest patch including the stuff from #10 is attached.

i cant seem to find the bug in #9
for some reason instead of parent => menu-name:x it submits parent => array(menu-name:x)
@Wim Leers: this is probably an easy one for you to fix, I've already spent a lot of time on this so now I'll just temporarily code an extra submit handler to fix it as I need to move on. Hope to see you pick this up soon so it can be handled the proper way.

wim leers’s picture

Status: Needs work » Fixed

These issues originate from the fact that I was simply using my demo module only, not the integration with the rest of Drupal (e.g. on node forms). Thanks for diving in and tackling the problems! :)

- I fixed the whitespace errors you introduced. You introduced not only new spaces where they shouldn't be, but you changed the indentation of A LOT of code blocks. Why would you do such a thing, I wonder? If you didn't do it manually, I'd like to know which editor you use so I can avoid it forever.
- The changes you made to hierarchical_select.module ($config['params']['type'] = $complete_form['type']['#value'];) are not acceptable.
- The changed module weight is not necessary on my vanilla Drupal 7 site, so it must be a problem specific to your site.
- I added a fix to hs_menu_hierarchical_select_valid_item(): the menu name is now being properly validated as well.
- I removed the ability to select node types for which HS Menu should be enabled: HS Menu improves scalability in all cases, hence it makes no sense to only show this in *some* cases.
- Problem described in #9 reproduced. I've implemented a work-around.

So, in short: all your bug-fixing changes have been incorporated, and where necessary improved and the last bug you discovered has been fixed, BUT your new functionality has *not* been added.

I hope this satisfies you :) I didn't actually have the time to work on this (I need to work on some other projects first), but I did anyway, as my token of gratitude for your contributions.

Here's the commit: http://drupalcode.org/project/hierarchical_select.git/commit/f54ca76.

rv0’s picture

Thanks a lot!

- I noticed the whitespace things introduced, but it was too late by then, sorry for that.. I auto format all my code using Netbeans. Will recheck my settings vs. Drupal Coding Standards. Things might have gotten lost since I updated from 6.8 to 7.0.
- The changes I had made passing on the type were indeed a bit dodgy in retrospect. I will create an issue for this as it seems HS Menu is currently breaking content's available menu settings.
- The weight thing also happened on a vanilla dev install for me. Menu and HS have the same weight.. I guess HS has to have its form alter happen after Menu in order to work. I think I read somewhere that same-weight modules go in alphabetical order? Will open new issue if I can reproduce it with latest patch.
- ok
- The ability to select node types is a very important one to me. HS is an improvement, but it also collides with any other menu altering modules that modifies the node edit page. Selecting node types is a workaround and was perfect for my need. Will open a separate issue to see if there are other options to make HS and other modules more compatible with each other.
- nice to see you fixed #9.. I had done a dirty fix by adding extra submit handlers that flatten the array, but didn't post it ;)

So thanks for reviewing my patches and correcting them.
I'll post some feature requests the next couple of days and I'm willing to fill them in myself. I hope you'll find the time to provide some guidance/advice in them.
I'll try to improve the quality of any patches in the future too (read: minus the whitespace issues).

wim leers’s picture

- Netbeans ARGH! :P I have nothing but bad experiences with Netbeans! I hope it treats you better. (It even broke my web browser, because its installer messed with OS internals…)
- Module weight: modules with the same weight are indeed executed in alphabetical order IIRC.
- HS Menu per type colliding with other modules: interesting, which ones? Thanks for opening a separate issue.

Thanks again for your contributions! :) Much appreciated!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.