Jasa Pembuatan Aplikasi Murah Berkualitas
konsultasi gratis sekarang

How To Use JHtmlSidebar::addFilter

Published on Saturday, Feb 1, 2014

If you are developing Joomla 3.x components you should familiar with this code:

JHtmlSidebar::addFilter(
	JText::_('JOPTION_SELECT_PUBLISHED'),
	'filter_published',
	JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), "value", "text", $this->state->get('filter.state'), true)
);

This code will create a drop down list to filter the items based on their state. This JHtmlJGrid is defined on /joomlapath/libraries/cms/html/jgrid.php and you can see the available options on jgrid.publishedOptions function. Here are the complete list:

$options[] = JHtml::_('select.option', '1', 'JPUBLISHED');
$options[] = JHtml::_('select.option', '0', 'JUNPUBLISHED');
$options[] = JHtml::_('select.option', '2', 'JARCHIVED');
$options[] = JHtml::_('select.option', '-2', 'JTRASHED');
$options[] = JHtml::_('select.option', '*', 'JALL'); 

So if you want to show only some options on the filter drop down list you can use the following code: 

//show Trash and All option only
$options        = array();        
$options[]      = JHtml::_('select.option', '-2', 'JTRASHED');
$options[]      = JHtml::_('select.option', '*', 'JALL');
JHtmlSidebar::addFilter(
	JText::_('JOPTION_SELECT_PUBLISHED'),
	'filter_published',
	JHtml::_('select.options', $options, "value", "text", $this->state->get('filter.state'), true)
);

 

Bagikan


Tags