Hi All,

(first sorry for my bad english)

I'm trying to create a "glossary view" like the existing "Glossary" view provided by default, but based on TAXONOMY instead of NODE, to obtain a list of terms in my vocabulary, with the attachment "alphabetical filter" above the list (looks like exactly as the default "Glossary" view, but with terms listed instead of nodes).

I recreated all the displays and conditions like the default "Glossary" views, but obviously I first choose the "taxonomy" option instead of "node" in the "based on" section in "add new view" action.

Well, I obtain the error you can see in the image attached.

I've attached my view also, if it can be useful.

Thank you for works!

MXT

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

I made some progress on this patch:

The glossary is not working perfect in d7.


    if (!empty($this->definition['many to one'])) {
      if (!empty($this->options['glossary'])) {
        $this->helper->formula = TRUE;
      }
      $this->value = array($argument);
      $this->helper->ensure_my_table();
      $this->helper->add_filter();
      return;
    }

This part of argument_string::query is the problem. It adds a multi to one filter.
So let's see what add_filter does.



  function add_filter() {
    if (empty($this->handler->value)) {
      return;
    }
    $this->handler->ensure_my_table();

    // Shorten some variables:
    $field = $this->get_field();
    $options = $this->handler->options;
    $operator = $this->handler->operator;
    if (empty($options['group'])) {
      $options['group'] = 0;
    }

    if ($operator == 'not') {
      $this->handler->query->add_where($options['group'], $field, NULL, 'IS NULL');
    }
    elseif ($operator == 'or' && empty($options['reduce_duplicates'])) {
      if (count($this->handler->value) > 1) {
        $this->handler->query->add_where($options['group'], $field, $this->handler->value, 'IN');
      }
      else {
        $this->handler->query->add_where($options['group'], $field, $this->handler->value);
      }
    }
    else {
      $field = $this->handler->real_field;
      $clause = $operator == 'or' ? db_or() : db_and();
      foreach ($this->handler->table_aliases as $value => $alias) {
        $clause->condition("$alias.$field", $this->handler->value);
      }

      // implode on either AND or OR.
      $this->handler->query->add_where($options['group'], $clause);
    }

The problem is that add_where currently just allows to have formulars or placeholders, because dbtng has where and condition, and just condition has placeholders, but where is needed for SUBSTRING(foo)

juves’s picture

subscribe

slashrsm’s picture

subscribe

dawehner’s picture

Status: Active » Needs work
FileSize
5.09 KB

Add some updated code.

dawehner’s picture

Some updates

iamjon’s picture

Status: Needs work » Needs review

setting status

dawehner’s picture

Status: Needs review » Needs work

Mh

dawehner’s picture

Status: Needs work » Needs review
FileSize
9.32 KB

Wow here is a working patch

dawehner’s picture

FileSize
5.21 KB

Merged out the vpr/views_debug stuff :)

dawehner’s picture

Status: Needs review » Fixed

Review doesn't offered something new.

Commited to the 7.x branch.

Dave Reid’s picture

Status: Fixed » Active

This causes a PHP notice with some coditions. if $operator == 'and' then $value is not defined ever. It should likely default to $this->handler->value.

Dave Reid’s picture

Status: Active » Needs review
FileSize
426 bytes
dawehner’s picture

Status: Needs review » Fixed

Thanks! Commited to the 7.x branch.

Dave Reid’s picture

Status: Fixed » Active

Hrm, this ended up causing more problems with another view. Leaving open until I can find what's wrong.

dawehner’s picture

FileSize
4.65 KB

Does this patch fix the issue?

Dave Reid’s picture

Status: Active » Reviewed & tested by the community

It works for me.

David_Rothstein’s picture

I also had a problem using a view with $operator == 'and', and this patch fixed it for me too.

dawehner’s picture

Status: Reviewed & tested by the community » Fixed

Wow. Two patch reviews!

Commited to the 7.x branch.f

Status: Fixed » Closed (fixed)

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

asb’s picture

Coming from #271833: Taxonomy depth for filters and exposed filters, looking forward to a stable release of 6.x-3.x with a backport of a "Taxonomy: Term ID (with depth)" filter for views based on taxonomy ;)