Which taxonomy related module should I choose?

mkrakowiak - November 18, 2008 - 13:42

Our website has several vocabularies each containing multiple terms put in a specific hierarchy. As we want to save the lineage of the selected terms, we need a solution that will automatically save the entire lineage for a selected term.

For example if term Catalyst is selected from the tree below for a given node:

About Us
--Publications
----Catalyst

we want the node to belong to the About Us and Publications categories as well. I know that this is handled by Hierarchical Select, but using the module would require to know that Catalyst is under About Us section, so it's not really a good option.

I checked the Suggested Terms and Taxonomy Super Select modules and they could be an option, especially the Suggested Terms module (as Taxonomy Super Select works in a similar way as the Hierarchical Select), but they don't have the option of saving the entire lineage for a given term.

It would also be great if there is a module that allows to search for a term in all vocabularies.

Is anyone aware of a module that does that?

i don't know of a module

adixon - November 18, 2008 - 15:20

i don't know of a module that would do that, but if I understand right, you could think of this as an interface issue - i.e. when a term is selected in the hierarchy, all parent terms are automatically selected as well. I had this requirement for a project currently under development, and I did some theme hacking to accomplish it, starting with theme_taxonomy_term_select, which the taxonomy module runs before displaying the available list of terms to select. My theme override digs out the corresponding vocabulary and node type being edited and then alters the form element appropriately.

Thanks for your advice,

mkrakowiak - November 18, 2008 - 16:09

Thanks for your advice, Adixon. Would you be able to provide here the piece of code that does the job? That would be helpful not only for me, I guess.

Also, I should've been more specific - I'm aware that the Suggested Terms module is dependent on free tagging, which makes it easy to add terms to nodes. Yeah, it is an interface issue.

random thought.

dman - November 18, 2008 - 16:39

I don't know what the answer is to your question here, but I thought I'd link to
the many many different approaches at related modules :-( for comparison.

Depending on what you are really doing with this information ... are you aware of the taxonomy/term/n/all option?
Rather than add lots of redundant (deduceable) tags to all pages at edit time, I'd be looking at making the retrieval of the terms smarter by tracing the tree when needed. But it depends where you are coming from.

.dan.
if you are asking a question you think should be documented, please provide a link to the handbook where you think the answer should be found.
| http://www.coders.co.nz/ |

This is brilliant, Dan! I

mkrakowiak - November 19, 2008 - 04:22

This is brilliant, Dan! I mean the taxonomy/term/n/all option. I knew of other taxonomy paths like taxonomy/term/1,2 or taxonomy/term/1+2, but somehow I wasn't aware of the /n/all... Thanks for pointing this out. I knew that the taxonomy system in Drupal was great but this feature comes in really handy.

So, this will definitely do the job in my case. I hope the recursion used in this case won't have a huge impact on performance of our website - I don't think there are more levels in the taxonomy hierarchy than 4 or 5.

Well, now what's left to do is to update all the taxonomy URL aliases :)

Hidden Magic.

dman - November 19, 2008 - 05:14

Glad it helps. It's better architecture IMO also.

There once was a snippet/patch/discussion on making a switch for the /all behavior to be a default globally (save you remaking aliases, and supports system-generated term links also - which will be hard for you).
IIRC the proponant started ranting that of course that should be the way everybody wants their taxonomies displayed, obviously ... so he alienated everyone and it never happened.
Maybe I misremember.
I still think a global option would be handy.

.dan.
if you are asking a question you think should be documented, please provide a link to the handbook where you think the answer should be found.
| http://www.coders.co.nz/ |

Mmmm maintenance

mkrakowiak - November 19, 2008 - 06:15

Yes, maintaining this will be time consuming and tedious. I think the global option for creating /all paths by default would make sense. Or at least an option to turn this on and off.

BTW, I searched for the snippet that you mentioned and found the Taxonomy Force All module. It looks like this will do the job.

yeah, it needed a search - I left that in your court ;-)

dman - November 19, 2008 - 07:22

That looks lik an answer.

This module solves this by simply implementing a hook_init() function that catch if requested page is taxonomy/term/x and transform it into taxonomy/term/x/all.

sounds pretty screwy to me, but it works without core mods, and kudos for explaining the method up-front in the module page!
Worth a crack.

better than Taxonomy Force All

mkrakowiak - November 19, 2008 - 20:01

Dan, what, in your opinion, would be a better solution than this module?

meh

dman - November 19, 2008 - 23:36

Better may be a simple core tweak to taxonomy_term_page() that uses a global setting.
But for a third-party module approach, taxonomy_force_all is OK, I guess.
It's possible to write a small module to hijack taxonomy/term/n paths altogether, figure out the request and pass it on to taxonomy.module to do the work. I'd be trying that ... but it's just a matter of style.

... Either that or Views. ... Taxonomy: Term ID depth modifier appears to be available, but I couldn't see where to set a default for it.

.dan.
if you are asking a question you think should be documented, please provide a link to the handbook where you think the answer should be found.
| http://www.coders.co.nz/ |

I've been testing the module

mkrakowiak - November 20, 2008 - 18:58

I've been testing the module and it works well. There is an option of actually switching to use hook_link_alter instead of hook_init, which is a good thing, I guess. Anyway, thanks for all your advice, Dan - dman.

 
 

Drupal is a registered trademark of Dries Buytaert.