1

How can I add a where clause in custom filter handler for views query.

I need to add where clause to alter views query using custom filter handler.

My code in custom filter:

class fee_management_handler_filter_payment_status extends views_handler_filter_many_to_one {
  function get_value_options() {
    $this->value_options = array('1' => 'Paid', '0' => 'Unpaid');
  }

    /**
        * Called to implement a payment status.
    */  
    function query() {  

        if filter = unpaid or 0 

        view conditions  + = ' AND pid IS NULL';    

        parent::query();
    }
}
1
function query() {
        parent::ensure_my_table(); #$this->ensure_my_table();
        $alias = $this->table . '_' . $this->view->base_table;
        $operator = ($this->value['0']) ? 'IS NOT' : 'IS';
    $this->query->add_where(0, $alias . '.pid', NULL, $operator . ' NULL');
        #debug($this->query);   
        parent::query();
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.