Community & Support

Extending Glossary Module Question

First off let me just say thanks for all the great tidbits of info I have gotten from all your posts. It's really helped me a TON in my Drupal installation and configuration.

What I am trying to do now is to extend the Glossary Module, and I'm having some problems. I am trying to get the Glossary to only pull a subset of all the available terms in a taxonomy based on where the page being displayed falls in the taxonomy.

For example, if the page is set in the taxonomy as "foo" then I'd like the Glossary to only pull terms whose parent is "foo" as well, right now it gets the ENTIRE taxonomy. That way the glossary will only flag terms related to "foo" rather than searching the entire taxonomy and maybe flagging terms on that page with stuff that has nothign to do with the actual content on that page.

I've narrowed it down to just changing the db_query in the _glossary_get_terms() function, but my problem is that I can't figure out how to let the glossary module know what the page's taxonomy is. Since the glossary is a filter, I can't send it the $node information (can I?).

Any ideas on how I could make this filter "node aware"?
Does my explanation of the problem make sense?

Comments

well, I hacked it in and got

well, I hacked it in and got it working. I ended up getting the request_uri() and chopping off the node id and using that to get node information. Once I had the node ID I could get the taxonomy ID for the page, once I had the taxonomy ID for the page I just altered the get_terms query to look for only terms whose parent matched the taxonomy ID of the page. Works really well, now I can set my page to a term in the taxonomy and the glossary will only flag terms that are it's children, in essence giving you now an unlimited number of glossaries.

best way

until filters become 'node aware', your approach is the best/only way to do this.

Thanks so much - at least I k

Thanks so much - at least I know now that I'm not goin nuts. It actually works quite well just as long as the taxonomy is set up correctly and the pages are all linked to the correct taxonomy as well.

Also added in a line of code

Also added in a line of code to add the definition of the term to the title attribute of the tag. It strips out all the quotes so it won't break your html and truncs the string to 90 characters so you still get the nice elipses if it goes over the 80 odd character limit. Now I don't have to even worry about using the nicelinks module because the tooltips take care of it.