I'm looking to update the taxonomy_context module to have taxonomy based breadcrumbs link to designated nodes instead of taxonomy/term pages.

Background

I'm designing a hierarchical site and plan on making good use of the core taxonomy module, taxonomy_access, and taxonomy_context. taxonomy_context is especially useful for hierarchical sites because it:

  • Generates breadcrumbs based on taxonomy, and
  • Allows me to display a description of a term (or vocabulary) on taxonomy/term pages.

Proposal

I'd like update the taxonomy_context breadcrumb links to do more than display the term description along with the normal taxonomy/term pages. I want the breadcrumb links to land on an associated "homepage" node for each taxonomy term. I do not want to see the summary list of nodes that the taxonomy core module provides. For example, if I clicked on an "about" breadcrumb, it takes me to a page node I have associated with the "about" term, not the normal taxonomy/term page.

After digging into the taxonomy core and taxonomy_context code I discovered modules don't have control over the summary list of nodes the taxonomy core module outputs (someone please correct me if I'm wrong here). For example, taxonomy_context inserts the taxonomy description above the normal taxonomy core module output--I want the breadcrumb to link to a node without showing the taxonomy core output. The nodes associated with taxonomy terms will be stored in a database table.

I think the easiest way to achieve my goal would be change all taxonomy based breadcrumb links to "taxonomy_breadcrumb/term/X" and register for the "taxonomy_breadcrumb/term" in hook_menu. The registered callback would then display the associated node, or the normal taxonomy/term/X page if no node association was found. The taxonomy/term path remains unchanged and still usable--the breadcrumbs would just point to the new taxonomy_breadcrumb/term instead.

Request for Comments

I'm looking for comments and input on this strategy as I'm relatively new to drupal. I'm also looking for input from the taxonomy_context developers. Is this something I should submit as a patch to the taxonomy_context module? Keep in mind this would require the module to create a database table (it currently has none). I could always create a separate module, but the "synergies" with taxonomy_context are substantial.

Comments

nedjo’s picture

Thanks for considering adding to an existing module before starting a new one.

A key principle in taxonomy_context is to work with the core taxonomy urls. This contrasts with some other taxonomy modules, e.g., taxonomy_menu. So on the face of it your proposal doesn't fit well with the taxonomy_context approach, though I'd be happy to talk about it more.

Have you looked at taxonomy_assoc, http://drupal.org/node/19806? I believe it does some of what you're suggesting--associating a node with a taxonomy term.

If you want to eliminate and replace the display at taxonom/term/x, you could simply replace the core call it with another menu item (provided it was loaded after the taxonomy module).

_craig’s picture

> your proposal doesn't fit well with the taxonomy_context approach
Fair enough. For now, I think I'll start down the path of creating a new module. If at some point it makes sense to combine efforts with taxonomy_context or some other module I'd be happy to reevaluate the decision.

> Have you looked at taxonomy_assoc
I did look at updating taxonomy_assoc for 4.7 (the module page says it’s no longer being maintained), but from what I could tell the taxonomy_assoc shows a node along with the normal taxonomy/node output, not instead of. (Disclaimer: I didn’t have a 4.6 install to actually try this and know for sure, I just looked at the code to deduce this).

> you could simply replace the core call ...with another menu item
It’s funny you mentioned this. I had tried registering for taxonomy/node in hook_menu, but it didn't work. Based on your comment, I'm now guessing it had to do with the order the hook_menu's are called. Anyone know if there's a way to ensure my hook_menu gets priority over the core taxonomy module?

Jaza’s picture

I like your ideas, but I don't think you'll need to develop a new module to do what you want. Have a look at the category module (4.7-compatible only). This module creates categories (i.e. terms) and containers (i.e. vocabularies) as nodes, which you can give body text to just like any other node.

The category package also includes several other modules, including category_menu (for generating menu links, which in turn provide navigation blocks and breadcrumbs), and category_display (for things like generating a table of contents, turning off node listings like you want, and providing book-module-like navigation links).

It sounds like your needs are very similar to the needs that I had a year ago, which is why I developed the category module. I started out using taxonomy_context, but found (like you) that by staying within the boundaries set by taxonomy, it wasn't able to fully meet my needs. Category is still in beta, but people are now starting to use it for their production sites; and although I don't guarantee that it's bug free, most people are finding that it works without any problems.

Jeremy Epstein - GreenAsh

Jeremy Epstein - GreenAsh

_craig’s picture

Thanks for the suggestion. For now I want to stick to using the core taxonomy module as much as possible. However, the category module seems quite promising. I'll have to keep an eye on it as it finishes up going though the beta process.

kae’s picture

we've been trying to do this also

dbenton’s picture

Any luck? Any developments?

I am interested in the same functionality, but haven't the time to do all of the digging through the code at the moment. If there's anything I can do to help, let me know.

_craig’s picture

I've thought through the concept a bit more and formulated some thoughts.  I've also started coding and I hope to have something available shortly after the release of 4.7.  Also, I'll appreciate any help I can get--thanks for the offer!  I've requested a CVS account and I'd like to get what I have in CVS soon.

The goal is to provide a module that will generate taxonomy based breadcrumbs on node pages, where the breadcrumbs link to the normal taxonomy/term pages or to administrator defined pages:

[HOME] >> [VOCABULARY] >> TERM >> [TERM] ...

  • The HOME breadcrumb (if present) will link to the homepage.  The text displayed for HOME should be administrator configurable.
  • The VOCABULARY breadcrumb (if present) will link to an administrator defined page (node).
  • Each TERM breadcrumb will link to either (1) taxonomy/term/tid by default, or (2) an administrator defined page (node) if one is defined for the term.
  • These administrator defined "breadcrumb links" for VOCABULARIES and TERMS should be controlled from the add/edit vocabulary and add/edit term administrator pages. 

Examples:
home >> term >> term
mysite >> term >> term
home >> vocabulary >> term >> term
vocabulary >> term >> term

_craig’s picture

Update for anyone interested. I've got a preliminary version of this new module. It needs more work and lots of testing! Once I figure out how to get it into CVS I'll do so.

_craig’s picture

See http://drupal.org/node/61944 for the beta of taxonomy_breadcrumb. You'll need to pull it out of cvs.