list_items "custom" filter

Hello,

Still here, loving Fuel CMS ! :)
I am trying to make a small change in filters, but can not get things to work the way I would like to.

I have a brand and country filter, and i would like for the select to be: where (country in ("",$this->filters['country']) and brand in ("",$this->filters['brand']))
so that I get all the entries where country is either the one I selected or empty and brand is either the one i selected or empty.

I am able to make the correct where statement, but by default, the parent list_items will add :
AND (LOWER(country) LIKE "%country%" OR LOWER(brand) LIKE "%brand%")

How can i prevent the parent from adding another where clause ?

Cheers,
Xavier.

Comments

  • edited April 2022

    You can try something like the following within your list_items method:

    if ($this->input->get_post('country'))
    {
        $this->db->group_start(); // <- Optional but ensures that the query condition is contained
        $this->db->where_in('country', $this->input->get_post('country'));
        $this->db->group_end(); // <- Optional
        unset($this->filters['country']); // <- Important
    }
    
  • I'll try that, thanks a lot !

Sign In or Register to comment.