View Handler methods "query()" and "pre_render()"

Events happening in the community are now at Drupal community events on www.drupal.org.
jeff00seattle's picture

Hi

What is the purpose of the View handler method query()?

Using a skeleton class that traces the calling of the View handler methods, I see that method query() is called before method pre_render(). Is there an expected work flow relation between these two methods?

Thanks

Jeff in Seattle

Comments

Believe it or not, this is

merlinofchaos's picture

Believe it or not, this is documented in the Advanced Help:

http://views-help.doc.logrus.com/help/views/api-handlers

Let me know if that doesn't answer your question.

Some clarification on some of the method

jeff00seattle's picture

Thanks Earl

Some clarification about a couple of the

The description of the views handler methods from provided with this link http://views-help.doc.logrus.com/help/views/api-handlers is helpful.

However, I would appreciate some clarification pertaining to the description of method query(): What does it mean to add itself to the query?

Jeff in Seattle

Thanks

Jeff in Seattle

I think that if you look at

Scott Reynolds's picture

I think that if you look at other handlers query() methods you would find your answer. The sort answer is you add your modifications to the SQL query thats about to be run.

Looking at views_handler_argument_numeric i see

<?php
function query() {
   
$this->ensure_my_table();

    if (!empty(
$this->options['break_phrase'])) {
     
views_break_phrase($this->argument, $this);
    }
    else {
     
$this->value = array($this->argument);
    }

    if (
count($this->value) > 1) {
     
$operator = empty($this->options['not']) ? 'IN' : 'NOT IN';
     
$placeholders = implode(', ', array_fill(0, sizeof($this->value), '%d'));
     
$this->query->add_where(0, "$this->table_alias.$this->real_field $operator ($placeholders)", $this->value);
    }
    else {
     
$operator = empty($this->options['not']) ? '=' : '!=';
     
$this->query->add_where(0, "$this->table_alias.$this->real_field $operator %d", $this->argument);
    }
  }
?>

So it is adding the argument value to the query.

For questions like this I rely on the Views handlers merlinofchaos has already written to show me the way. A quick find all 'pre_query' will give you insight into what that does. Go explore thats what opensource is for.

Views Developers

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: