1

Does anyone know how to add custom filters for the Joomla module?

In my helper.php I have this code. but doesn't work

public function __construct($config = array()) 
{
    if(empty($config['filter_fields'])) {
        $config['filter_fields'] = array(
            'value', 'value'
        );
    }
    parent::__construct($config);
}

public function populateState($ordering = null, $direction = null) 
{
    $search = $this->getUserStateFromRequest($this->context.'.filter.search', 'filter_search');
    $this->setState('filter.search', $search);
    parent::populateState('id', 'desc');
}

I have a folder forms and inside it has filter.xml

in the tmpl folder. the in the default.php this is my code

<?php
    // Filter Search tools bar
    echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this));
?>
Jainil
  • 1,488
  • 1
  • 21
  • 26
Rhea Lorraine
  • 67
  • 1
  • 7
  • This will get a better answer on the [joomla.se] stack exchange site. – Elin Oct 19 '19 at 11:14
  • I'll need some more info. Is this a stand-alone module or is it with a component? what kind of data are you trying to filter? In short you will submit some data from a form to the model, you then add that to the DB query to change the results that are displayed. So from what you have above you need to add another $this->setState for the field you are filtering then modify the db query to use that info. – Blueline Jan 05 '20 at 06:07

0 Answers0