i'd like to use comma separated list of terms at taxonomy term name argument. it will be possible in the future?

thank you for your attention.

Comments

merlinofchaos’s picture

If someone provides a patch, it might.

dayre’s picture

The future is NOW (though not in terms of a patch):

http://drupal.org/node/54455#comment-239583

catch’s picture

Version: 5.x-1.x-dev » 6.x-2.x-dev
Component: Views Data » Code
Gábor Mayer’s picture

tql is an alternative for filtering by term name

amitaibu’s picture

Component: Code » Documentation
Status: Active » Fixed

This issue is already implemented in Views 2. In order to use it:

1)enable the views provided taxonomy_term.
2) From all the existing arguments from the 'Arguments'.
3) Add 'Taxonomy: Term ID' argument with the following settings:
title = Content tagged with: %1
Validator =
Allow multiple terms per argument - Enabled.
4) Save the view.

On a side note having TQL module ported to D6 could be nice :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

nikosnikos’s picture

Component: Documentation » taxonomy data
Status: Closed (fixed) » Needs review
StatusFileSize
new47.31 KB
new3.48 KB

The solution proposed in #5 didn't work for me so I wrote a patch.

I haded a new "argument type" in the "validator options" field in "Taxonomy term ID" argument. By selecting it, it is possible to have multiple term names in argument like .../Joe,Benny B.,Hakim/

The limitations are :

  • There's no caching system
  • I didn't test synonyms.
  • It only works for comma separated names ('and' operator).

The patch add this to validate_argument function in views_plugin_argument_validate_taxonomy_term

      case 'converts':
        // This works only for terms separated by , 
        // TODO : Make it work for terms separated by +
        $tnames = $tnames_orig = drupal_explode_tags($argument);
        
        $placeholders = implode(', ', array_fill(0,count($tnames),"'%s'"));

        // Add $tnames at the end of $tnames because there's two sql where clauses
        foreach ($tnames as $value) {
          $tnames[] = $value;
        }

        // TODO : A caching system is missing
        // TODO : Test transform and synonyms
        if ($transform) {
          $result = db_query("SELECT replace(td.name, ' ', '-') key_name, td.* FROM {term_data} td LEFT JOIN {term_synonym} ts ON ts.tid = td.tid WHERE (replace(td.name, ' ', '-') in ($placeholders) OR replace(ts.name, ' ', '-') in ($placeholders))", $tnames);
        }
        else {
          $result = db_query("SELECT td.name key_name, td.* FROM {term_data} td LEFT JOIN {term_synonym} ts ON ts.tid = td.tid WHERE (td.name in ($placeholders) OR ts.name in ($placeholders))", $tnames);
        }
        
        $tids = array();
        
        while ($term = db_fetch_object($result)) {
          // TODO : Check this is relevant I'm not sure what it does
          if ($vids && empty($vids[$term->vid])) {
            return FALSE;
          }

          $tids[$term->key_name] = $term->tid;
        }

        $this->argument->argument = implode(',', array_unique($tids));
        $this->argument->validated_title = check_plain(implode(',',$tnames_orig));
        // If there's not the same number of tids than names in the original argument, we did not find a term.
        return ( count($tids) == count($tnames_orig) );
dawehner’s picture

Status: Needs review » Closed (duplicate)

There is another issue about exactly this topic: #1248300: Contextual filters: Taxonomy filter validation using multiple term names
There a quite well written patch is added so mark this as duplicate. I'm sorry that this patch so basically got lost, but
it's indeed a problem how bigbigbig the queue is, and you even can't find out what all kind of patches are in.
Thanks for providing a patch anyway.