Support for a term with multiple parents

webel - June 22, 2009 - 00:24
Project:Taxonomy Menu
Version:6.x-2.3
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs work
Description

Not sure whether Nice Menus implicated, but I doubt it.

See for example child term 'hemp' under parent 'agriculture' (gets listed ok), and under 'textiles' at http://www.ethicalemarket.com.
The Products menu generated using Nice Menus and Taxonomy Menu together gives 'hemp' twice under 'agriculture' and nothing
under 'textiles'.

Note that a Taxonomy TreeMenu picks up the double-parent correctly !

And so does SiteMenu: http://www.ethicalemarket.com/sitemenu

#1

webel - June 22, 2009 - 01:35
Version:6.x-2.x-dev» 6.x-2.3

#2

whodies - June 23, 2009 - 02:55

I'm dealing with this problem right now. I gather that the module is built under the premise that you need one menu item for one term in every vocabulary.

Take the _taxonomy_menu_get_mlid function for example.

function _taxonomy_menu_get_mlid($tid, $vid) {
  return db_result(db_query('SELECT mlid FROM {taxonomy_menu} WHERE tid = %d AND vid = %d', $tid, $vid));
}

This function assumes that every term has only one menu link assigned to it, and it looks like it's pretty fundamental to the module. It'll take some rewriting to get the whole thing to work on multiple parents per term.

I'll probably have to take care of this to finish my project anyway so if anyone's interested I`ll post a hacked version of this when I`m done (dont expect it to be too professional or stable though).

Apart from this issue, this is really a wonderful module, especially when combined with NAT.

Thanks a lot!

#3

indytechcook - June 23, 2009 - 11:14

That is a correct assumption. It's being worked on as part of V3. It's not a complete rewrite (like V1 to V2) but close.

http://drupal.org/node/432048

#4

webel - June 25, 2009 - 00:26

Thanks @indytechcook and @whodies for your attention to this. I am BTW also having trouble with Vocubulary TreeMenu (it does not seem to catch parenting changes), so I am currently without any module that will handle my taxonomy, which is seriously holding my launch of this site. So I will follow your updates with great interest.

#5

webel - June 25, 2009 - 00:34

@whodies, who wrote:

I'll probably have to take care of this to finish my project anyway so if anyone's interested I`ll post a hacked version of this when I`m done (dont expect it to be too professional or stable though).

Well as long as it doesn't mangle my menu structure (like in #498226: Primary Links menu completely mangled, and stayed mangled after switching off module !) it can't be worse than getting no other answers or suggestions.

#6

webel - June 26, 2009 - 11:21

Bumping to remind how much I'm looking forward to testing and using a solution.

#7

webel - July 1, 2009 - 09:52

C'mon guys, let's celebrate the new financial year with a taxonomy menu that can handle terms with multiple parents, even as devel status. I'm at the point now where I will have to write my own module, because there are 2 others that can't handle this. Or I'll have to hack/mend/fix/patch yours. I can't wait weeks.

Grateful for what you have done, delighted if you can release something that works for me now (meaning hours or a day or two).

I've wasted now days on this and Taxonomy TreeMenu; and neither will handle terms with multiple parents (which I 100% need).

Webel

#8

webel - July 1, 2009 - 09:53

@whodies Please be my heroic coder hero (lest I have to be somebody else's). Webel

#9

indytechcook - July 1, 2009 - 13:39

Webel. My new daughter has taken priority over my VOLUNTEER work. The wonderful part of the Drupal community is how the member's give back. I think this is a great opportunity for you to give back in the form of a patch.

I'm happy to commit the patch as I see it as a very useful feature.

Cheers,
Neil

#10

whodies - July 1, 2009 - 21:07

Im working on it webel, and it's far from easy. Please don't put your faith in what will ultimately end up as baddly hacked code. It might not even work on other people's sites. I'd love it if people were to benefit from my amateur level tinkerings, but I can't guarantee it.

#11

whodies - July 2, 2009 - 00:35

Well, if anyone's desperate enough , here's three files you need to replace in the taxonomy module. I haven't tested it properly. I dont even want to know what happens if you mark down a term as its own child.

I had to change the way the path was being created because obviously each term has to have a different path for each of its menu item links if you want the right menu item to be marked as active. I had to add a function or two as well for term\menu parent searching purposes.

Nevermind. I wont go into too many details. If indytechcook or webel or anyone else for the matter is interested in how this works (or is supposed to work anyway) I'd be happy to discuss the changes I've made. Like I said before, this is just the minimum I need to make my site work so dont expect uh .... anything at all.

AttachmentSize
taxonomy_menu_replacements.zip 9.53 KB

#12

webel - July 2, 2009 - 03:04

All caveats understood ! Will report back with findings. And many thanks, this action is exactly what I wished, an honest pragramatic attempt.

I dont even want to know what happens if you mark down a term as its own child.

ROTFL

#13

webel - July 2, 2009 - 08:51

@whodies

I installed 3 files taxonomy_menu_replacements.zip.

Good shot, worth another, it's within firing distance.

Terms with multiple parents are now shown correctly under the 1st parent,
and they are also under their 2nd parent,
however they are in addition now also shown at top level
(i.e. top within the vocab, I chose to exclude vocab as a menu item).

Please see the attached image, which shows a comparison with the correct Sitemenu.

Term 'babywear' has parents 'children' and 'clothing & fashion'.
It appears in the Taxonomy Menu correctly under the matching parent menus,
however note that it also occurs (alphabetically above) as a top level menu item.

I've set up a test page for you.
The Nice Menus in the left sidebar are built over a Secondary Links menu populated by this "patched" Taxonomy Menu, using a Products vocabulary with many cases of terms with multiple term parents.

You may also compare with the Site Menu by clicking on the Catalog button/link at the top.

Please only use the test page, as the Vocabulary Menu version only appears on that dedicated test page, elsewhere the Taxonomy TreeMenu (which is failing in other ways, and requires manual updates) is used.

It is now clear to me that Taxonomy Menu will probably be the way to go, so please give it another try,

most grateful,

Webel

PS: This was all done without changing the taxonomy, I'll report back on that next after parenting 'lily' and 'rose' terms.

AttachmentSize
Taxonomy_Menu_multiple_parent_test_secondary_links8_vs_sitemenu_babywear_CASE.png 82.33 KB

#14

webel - July 2, 2009 - 09:12

Ok, there are lots of other problems it seems.

I had a terms 'lily' and 'rose' created by free tagging, and they thus had no parents.
They can't be seen in the menu generated by this "patched" Taxonomy Menu (and I checked in the admin for the menu, too).
(They can be seen in other menu modules.)

When I moved 'lily' to 'gifts->flowers' it showed ok. See 1st and 2nd images.

So it seems that parentless terms won't show at the top-level (i.e. under the vocab).

However, notice that in the sitemenu view there is also 'gifts->flowers->bouquet', 'gifts->flowers->orchid', which were already present. These are missing from the menu created by Taxonomy Menu, even though they have many posting hits
See 3rd image.

AttachmentSize
Taxonomy_Menu_multiple_parent_test_secondary_links9_gift_flower_lily.png 2.98 KB
Taxonomy_Menu_multiple_parent_test_secondary_links9_gift_flower_lily_nice_menu.png 4.87 KB
Taxonomy_Menu_multiple_parent_test_secondary_links9_gift_flowers_bouquet_orchid_sitement.png 4.57 KB

#15

whodies - July 2, 2009 - 10:59

here, this might fix it

AttachmentSize
taxonomy_menu_module.zip 7.5 KB

#16

webel - July 2, 2009 - 12:08

@whodies

I copied over new module, performed update, switched module off and on, regenerated menu .. it does not seem to have worked.

I've switched on node numbers, maybe that is a useful diagnostic. Please view again at test page.

Thanks for continued attempts .. there's an appreciative hint in there whodies.

Webel

#17

webel - July 2, 2009 - 12:15

It's now quite mangled, so much so that I can find no rhyme or reason to it, and unfortunately (as Murphy's law would have it) for some reason my test case 'gifts>flowers' is now completely gone (but still ok in the taxonomy and in sitemenu).

#18

whodies - July 3, 2009 - 05:15

Right.
I decided to stop tiptoeing around this issue and just rewrite entire sections. So I axed a couple of them and removed about 200 lines of code which I found redundant. I added a few database query functions and modified one of the existing ones. Seems to be working ok now....

It gives out this 'duplicate-entry" warning message whenever I'm adding new rows to the taxonomy_menu table for reasons I dont understand at the moment but as far as I can see it doesnt damage anything.

give it a spin. this time I packed the whole module so you have to overwrite everything.

AttachmentSize
taxonomy_menu.zip 25.14 KB

#19

webel - July 3, 2009 - 09:42

@whodies

Downloaded, installed, module off/on, rebuilt menus. Still seems to fail somewhat.

To make comparison easier I've switched on the Vocabulary Menu so that it appears
on the same page as the sitemenu
(and Vocabulary TreeMenu is on elsewhere, so please ignore most other pages).

As before, 'babywear' (from 'clothing & fashion->babywear' and 'children->babywear') appears
under both of its parents, as well as additionally at the top level by itself.

Also, 'children (34)' and 'children' appear parallel at the top-level, where 'children(34)' has
only 'babywear' as its child, however 'children' has other children (excuse the menu pun).

I'm here for the next few hours and will test any updates, as well as tomorrow morning Sydney time.

And thanks for continued attempts.

Webel

#20

indytechcook - July 3, 2009 - 10:53

@webel, try disable, uninstalling (admin/build/modules/uninstall) then reenable module. This will whip out all prior existence of the module (menu items and such)

@whodies I'll be the first person to tell you that the code wasn't perfect. Optimization was on my list. Being that you have put a ton of hard work on this, would you like to be part of the taxonomy menu team? When I commited your changes, of course I would give you credit, but this way you could also have the commit.

#21

indytechcook - July 3, 2009 - 11:31

I've taken a quick look and the only comment I have is that some of the code you took out because it looked unnecessary was put in there for a reason.

For example, I had taxonomy_menu_taxonomy that same way at one time using and ran into issue because taxonomy_get_term pulls from a cache. So when you update the menu item, it will pulls the previous data.

Otherwise, pretty good work. I'll like this features and I'll work it into a release.

#22

whodies - July 3, 2009 - 14:32

@Webel
This is probably the last version I'm posting. I did my best to take care of the bugs I could reproduce. Unless I run into any of these problems in the future, its out of my hands.

@Indytechcook
I added a few small modifications and documented the new functions (I think the documentation for some of the existing functions I've changed is no longer valid).

About your example concerning the taxonomy hook, take a closer look and you'll see that taxonomy_get_term is being used only if the $op is 'delete' , otherwise its just the array given with hook converted into an object.

This is still a relatively half assed attempt on my part so I'm sure I screwed up a few things. I can't see any of them at the moment besides that duplicate-entry error. I've done very little testing though , so who knows ?

As for your offer, I am both flattered and compeletly unwilling to commit to it. I'm in enough trouble with my boss as it is for having taken the time to tackle this issue.

Again, thank you very much for developing this module in the first place, I appreciate it.

AttachmentSize
taxonomy_menu.zip 25.44 KB

#23

indytechcook - July 3, 2009 - 16:16
Title:6.x-2.3: term with mutiple parent appears twice under first parent, instead of under both parents: together with nice-menus» Support for a term with multiple parents
Category:bug report» feature request
Status:active» needs review

@whodies
your help will always be accepted :) Cheers

#24

webel - July 4, 2009 - 01:21

@whodies

There is no uninstall for this module.

It's absolutely completely scrambled, with terms with no possible relationship to each (let alone parent-child) within each other, and utter mess. Thanks for trying anyway.

I'm in enough trouble with my boss as it is for having taken the time to tackle this issue.

I am my own boss. My boss says:

"Not yet again weeks wasted without income because you trusted mostly unpaid open source process; I told you to do it yourself from the beginning properly, instead of half assed or whatever. You've now told me about 2 modules that are still broken with terms with multiple parents, I'm sick of hearing about it after this long, just fix it !".

I told my boss that he is an !@#!@# and that I'm thinking of resigning to find a nicer boss.

I might indeed have to do it myself, as a fresh new module.

Webel

#25

indytechcook - July 3, 2009 - 23:36
Status:needs review» needs work

#26

webel - July 4, 2009 - 00:30

@whodies

As far as I can tell the rebuild of your last (and final) version does not work at all !

I had originally allocated secondary_links menu to use my product keywords vocabulary (with terms with multiple parents).
As already reported all I saw was a complete mess.
I then went to menu_links are removed deleted all rows with `menu_name` LIKE '%secondary%'.

Then after menu rebuild from the vocabulary I saw .. nothing.

So to be sure I created a whole new menu as a fresh container for a Vocabulary Menu. With and/or without rebuild I get .. nothing.

I suggest since you've said this would be your final work version and that it works for you (which I understand, you are under no obligation to me) that you double check it for yourself. As far as I can tell it is badly broken.

#27

webel - July 4, 2009 - 00:58

I tried reinstalling and rebuilding the version http://drupal.org/files/issues/taxonomy_menu_3.zip.
I again could not populate a fresh menu container at using it, which I had not tried previously, because it promises:

Select to rebuild the menu on submit.
Rebuild the menu on submit. Warning: This will delete then re-create all of the menu items. Only use this option if you are experiencing issues.

Neither http://drupal.org/files/issues/taxonomy_menu_3.zip nor http://drupal.org/files/issues/taxonomy_menu_4.zip does this on my product taxonomy.

I might create a mini test taxonomy and report back.

#28

webel - July 4, 2009 - 01:28

Mini test fails to build or rebuild at all using http://drupal.org/files/issues/taxonomy_menu_3.zip or http://drupal.org/files/issues/taxonomy_menu_4.zip.

See attached image of the test taxonomy. I tried to populate a completely fresh test menu container. fails completely.

#29

webel - July 4, 2009 - 01:26

I reinstalled 6.x-2.3, and am back to square one. See attached image showing original problem, term with multiple parents appears twice under one parent.

AttachmentSize
VocabularyMenu_test_menu_head.png 24.06 KB

#30

webel - July 4, 2009 - 01:27

Attachment was missing from http://drupal.org/node/498182#comment-1773968.

AttachmentSize
VocabularyMenu_test_vocab.png 6.95 KB

#31

whodies - July 5, 2009 - 03:24

@webel , im sorry the rebuild didnt work out for you. It seems to work well enough for me, since the last post I didnt have to change anything. I suggest you look at least at the original module before you rebuild it completly, that's what I wanted to do at first but after some inspection I realised that the module doesnt need a complete reboot, most of the major changes were in the handler function, and rest was just comsetics. I hope you work it out one way or another.

#32

webel - July 5, 2009 - 07:22

@whodies Have read reply, thanks for trying. I am considering my options now in earnest.

#33

webel - July 5, 2009 - 10:49

I have removed all multiple parents from my taxonomy and 6.x-2.3 works fine. It was a lot of work. I'm investigating other ways of representing and exploiting taxonomy relationships to get away from the limits of a single hierarchy.

#34

webel - July 5, 2009 - 13:25

@whodies As a footnote, so to speak, I've discovered that I had two terms with themselves as parent, thanks to Taxonomy Manager it seems (after some merges gone wrong), as reported at: #482304: Circular hierarchical taxonomies are bad. This may be why the modules you prepared (which worked for you) failed for me. For the moment (until after my site is launched) I'm sticking with single parent terms, I will still experiment with your module versions elsewhere later.

@indytechcook Glad for news on tested support for multiple parents in upcoming versions.

Thanks both for input and coding attempts.

#35

Akela - July 26, 2009 - 20:35

@webel: Yes, there is an uninstall for this module. It doesn't show up until you deselect "Taxonomy Menu" in the module list and apply the changes.

@whodies: Thank you so much, you saved my life! You fix works perfectly.

#36

Akela - July 29, 2009 - 00:25

Here is an error I am getting when creating new nodes. I do not think it actually creates any problems (i.e., I am able to create the node regardless), but I decided to post it any way.

    * user warning: Duplicate entry '1076-96' for key 1 query: INSERT INTO latin_taxonomy_menu (mlid, tid, vid) VALUES (1076, 96, 7) in \sites\all\modules\taxonomy_menu\taxonomy_menu.database.inc on line 22.
    * user warning: Duplicate entry '1073-83' for key 1 query: INSERT INTO latin_taxonomy_menu (mlid, tid, vid) VALUES (1073, 83, 7) in \sites\all\modules\taxonomy_menu\taxonomy_menu.database.inc on line 22.
    * user warning: Duplicate entry '1042-50' for key 1 query: INSERT INTO latin_taxonomy_menu (mlid, tid, vid) VALUES (1042, 50, 5) in \sites\all\modules\taxonomy_menu\taxonomy_menu.database.inc on line 22.
    * user warning: Duplicate entry '1032-32' for key 1 query: INSERT INTO latin_taxonomy_menu (mlid, tid, vid) VALUES (1032, 32, 5) in \sites\all\modules\taxonomy_menu\taxonomy_menu.database.inc on line 22.
    * user warning: Duplicate entry '1017-13' for key 1 query: INSERT INTO latin_taxonomy_menu (mlid, tid, vid) VALUES (1017, 13, 5) in \sites\all\modules\taxonomy_menu\taxonomy_menu.database.inc on line 22.
    * user warning: Duplicate entry '1057-106' for key 1 query: INSERT INTO latin_taxonomy_menu (mlid, tid, vid) VALUES (1057, 106, 7) in \sites\all\modules\taxonomy_menu\taxonomy_menu.database.inc on line 22.

#37

whodies - July 29, 2009 - 05:13

I've already mentioned this issue a few comments back. Indeed, it seems to be pretty harmless, but I'd be happy to get rid of it if I only knew why it was happening.

#38

temp - September 18, 2009 - 15:12

@indytechcook, this changes been applied in 2.4-beta1 version?

#39

indytechcook - September 19, 2009 - 00:20

No it did not. There were to many changes to be in an incremental release. I have used part for the next version.

#40

temp - November 10, 2009 - 18:12

delete my - error post - sorry!

 
 

Drupal is a registered trademark of Dries Buytaert.