The current taxonomy system allows only one operator AND or OR when recalling nodes form /taxonomy/term/.... Te terms in the url can be ANDed (using commas) or ORed (using plus), but you can not mix AND and OR to get more complex filters.
Examples:
- http://drupal.org/taxonomy/term/51,77 selects nodes having "Paid Drupal services" AND "Drupal 5.x";
- http://drupal.org/taxonomy/term/51,77 selects nodes having "Paid Drupal services" AND "Drupal 4.7.x";

If you want to select nodes having "Paid Drupal services" AND then ... "Drupal 5.x" OR "Drupal 4.7.x";, you might want to use an url like http://drupal.org/taxonomy/term/51,47+77, but it shows page not found. This happens because function taxonomy_terms_parse_string() can accept one operator only.

The attached patch allows both commas and plus in the taxonomy url, and builds a query with the terms ANDed and/or ORed together. The patch is against the latest cvs version of taxonomy module, v1.335).

CommentFileSizeAuthor
taxonomy.module_36.patch6.69 KBstefano73

Comments

wim leers’s picture

Version: 6.x-dev » 7.x-dev

Cool idea. This will have to wait until 7.x though.

T1TAN23’s picture

How do I implement this in my custom search form?

I am excited to see this patch, but I am curious to know how to modify my custom search form in a way that will allow for both the '+' and the ',' so that when the keywords are entered into the search form it does both the AND'd and OR'd search together on the same keywords. The site I am working on is for a medical supply catalog and suppose the user was searching for Latex Gloves, the client would like to see the search conducted like...

search/node/latex,gloves+latex+gloves

The next question would be, how would I go about ordering the results so that the AND'd results always ranked higher than the OR results? (unless of course there were no AND results)

Finally, would searching this way cause duplicates in the search results?

I'll be your bestest drupal buddy ever if someone can help me pull this off :)

wim leers’s picture

Status: Active » Closed (won't fix)

This is being removed in D7. Hence extending this functionality makes no sense.

andypost’s picture

Status: Closed (won't fix) » Needs work

This is not removed!
http://api.drupal.org/api/function/taxonomy_select_nodes/7 still there so it's easy to implement

A lot of sites uses taxonomy/term/X,Y so why this functionality broken?

dave reid’s picture

Status: Needs work » Closed (won't fix)

There is a lot of other stuff broken in D7 in taxonomy.module. We're working on it and will get it cleaned up. But this is a very won't fix issue because the menu paths and calllbacks have changed to only allow one term. You can use views in D7 when it's ready for stuff like this.