Skip to content

Commit

Permalink
Possibility to remove filters individually when using the searchtools…
Browse files Browse the repository at this point in the history
… layout helper

Bring up a 'removedFilters' (array) option to the 'searchtools layout helper' that allows to remove/disable filters individually.

# Testing

To test it you can change the file:
administrator/components/com_content/views/articles/tmpl/default.php
on line 48:
echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this));
by: 
echo JLayoutHelper::render('joomla.searchtools.default', array(
        'view' => $this,
        'options' => array(
                'removedFilters' => array()
	)
)); 

Then, add one or more searchtools field name to the 'removedFilters' option array :
        'options' => array(
                'removedFilters' => array('filter_published', 'filter_category_id')
	)

and observe the result (filters removed) on the searchtools bar of:
/administrator/index.php?option=com_content&view=articles
  • Loading branch information
panopt committed Dec 22, 2015
1 parent ff084f7 commit 5e80a70
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions layouts/joomla/searchtools/default/filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,26 @@

// Load the form filters
$filters = $data['view']->filterForm->getGroup('filter');

// Remove the search filter
unset($filters['filter_search']);

// Introduced 'removedFilters' (array) option that lets remove filters
if (isset($data['options']['removedFilters']))
{
foreach ($data['options']['removedFilters'] as $removedFilters){
if (isset($filters[$removedFilters]))
{
unset($filters[$removedFilters]);
}
}
}

?>
<?php if ($filters) : ?>
<?php foreach ($filters as $fieldName => $field) : ?>
<?php if ($fieldName != 'filter_search') : ?>
<div class="js-stools-field-filter">
<?php echo $field->input; ?>
</div>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>

0 comments on commit 5e80a70

Please sign in to comment.