<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.sandbox.joomla.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Catanet</id>
	<title>Joomla! Documentation - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.sandbox.joomla.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Catanet"/>
	<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/Special:Contributions/Catanet"/>
	<updated>2026-08-15T22:53:34Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Configuring_Xdebug_for_PHP_development/Mac&amp;diff=118015</id>
		<title>Configuring Xdebug for PHP development/Mac</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Configuring_Xdebug_for_PHP_development/Mac&amp;diff=118015"/>
		<updated>2014-05-01T14:55:56Z</updated>

		<summary type="html">&lt;p&gt;Catanet: Created page with &amp;quot;== Configuring Xdebug with MAMP ==  === Prerequisites === These instructions are for Mac OS X (actually tested on version 10.9.2 Mavericks) with installed MAMP Application (ac...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuring Xdebug with MAMP ==&lt;br /&gt;
&lt;br /&gt;
=== Prerequisites ===&lt;br /&gt;
These instructions are for Mac OS X (actually tested on version 10.9.2 Mavericks) with installed MAMP Application (actually tested on MAMP version 3.0.4).&lt;br /&gt;
&lt;br /&gt;
=== Configuration instructions ===&lt;br /&gt;
*Open finder and navigate to&lt;br /&gt;
 &amp;lt;tt&amp;gt; /Applications/MAMP/conf/&amp;lt;selected php version&amp;gt;/ &amp;lt;/tt&amp;gt;&lt;br /&gt;
(NOTE: &amp;lt;selected php version&amp;gt; is the php version that you have selected in the MAMP configuration)&lt;br /&gt;
*Open the file &#039;&#039;&#039;php.ini&#039;&#039;&#039; with a text editor like e.g. TextWrangler&lt;br /&gt;
*Find the section [xdebug]&lt;br /&gt;
*Uncomment the line&lt;br /&gt;
&amp;lt;tt&amp;gt; &lt;br /&gt;
 [xdebug]&lt;br /&gt;
 ;zend_extension=&amp;quot;/Applications/MAMP/bin/php/&amp;lt;selected php version&amp;gt;/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so&amp;quot;&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
by removing the &#039;&#039;&#039;;&#039;&#039;&#039; character at the beginning of the line&lt;br /&gt;
*Add after the line the following text, if not already existing&lt;br /&gt;
&amp;lt;tt&amp;gt; &lt;br /&gt;
 xdebug.remote_enable=on&lt;br /&gt;
 xdebug.remote_handler=dbgp&lt;br /&gt;
 xdebug.remote_host=localhost&lt;br /&gt;
 xdebug.remote_port=9000&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
*Save changes and close the editor&lt;br /&gt;
*Restart your MAMP Server&lt;br /&gt;
Note: You can set a different port number if you need.&lt;/div&gt;</summary>
		<author><name>Catanet</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=J2.5:Creating_Mootools_accordion_or_simple_slider/toggler&amp;diff=107212</id>
		<title>J2.5:Creating Mootools accordion or simple slider/toggler</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=J2.5:Creating_Mootools_accordion_or_simple_slider/toggler&amp;diff=107212"/>
		<updated>2014-01-24T11:01:20Z</updated>

		<summary type="html">&lt;p&gt;Catanet: Fix: added closing &amp;#039; that was missing&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{version/tutor|2.5|platform=11.1|target=from}}&lt;br /&gt;
{{review}}&lt;br /&gt;
Simple example to create a simple accordion. Can also be used to make a simple slide-toggler (just use 1 link).&lt;br /&gt;
In this example all the accordions (slider) are closed by default.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;The php code (e.g. inside template):&#039;&#039;&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
//Add Slide/toggle behavior&lt;br /&gt;
JHTML::_(&#039;behavior.framework&#039;,true);&lt;br /&gt;
$this-&amp;gt;document-&amp;gt;addScriptDeclaration(&#039;&lt;br /&gt;
		window.addEvent(&amp;quot;domready&amp;quot;, function( ){&lt;br /&gt;
		navAcc = new Accordion( $$( &amp;quot;.accordion .accT&amp;quot; ), $$( &amp;quot;.accordion .accE&amp;quot; ), {display: -1, alwaysHide: true}  );&lt;br /&gt;
}&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&#039;&#039;Your html should look like this:&#039;&#039;&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;accordion&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;a class=&amp;quot;accT&amp;quot;&amp;gt;Link 1&amp;lt;/a&amp;gt;&lt;br /&gt;
	&amp;lt;div class=&amp;quot;accE&amp;quot;&amp;gt;Container 1&amp;lt;/div&amp;gt;&lt;br /&gt;
	&amp;lt;a class=&amp;quot;accT&amp;quot;&amp;gt;Link 1&amp;lt;/a&amp;gt;&lt;br /&gt;
	&amp;lt;div class=&amp;quot;accE&amp;quot;&amp;gt;Container 2&amp;lt;/div&amp;gt;&lt;br /&gt;
	&amp;lt;a class=&amp;quot;accT&amp;quot;&amp;gt;Link 1&amp;lt;/a&amp;gt;&lt;br /&gt;
	&amp;lt;div class=&amp;quot;accE&amp;quot;&amp;gt;Container 3&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Development‏‎]] [[Category:mootools]]&lt;br /&gt;
[[Category:JavaScript]]&lt;/div&gt;</summary>
		<author><name>Catanet</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Combo_form_field_type&amp;diff=105919</id>
		<title>Combo form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Combo_form_field_type&amp;diff=105919"/>
		<updated>2013-11-30T11:26:10Z</updated>

		<summary type="html">&lt;p&gt;Catanet: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Provides a combobox field.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the parameter.&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;combobox&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) tooltip for the form field.&lt;br /&gt;
* &#039;&#039;&#039;class&#039;&#039;&#039; (optional) specify your own classes for additonal markup, defaults to &amp;quot;combobox&amp;quot;&lt;br /&gt;
* &#039;&#039;&#039;readonly&#039;&#039;&#039; (optional) set to &amp;quot;true&amp;quot;, defaults to false, meaning editable.&lt;br /&gt;
* &#039;&#039;&#039;disabled&#039;&#039;&#039; (optional) set to &amp;quot;true&amp;quot;, defaults to false, meaning enabled.&lt;br /&gt;
* &#039;&#039;&#039;size&#039;&#039;&#039; (optional) sets the input size of the field&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; (optional) sets whether input is required, defaults to no input required.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;myeditbox&amp;quot; type=&amp;quot;combobox&amp;quot; label=&amp;quot;MyEditBox&amp;quot; description=&amp;quot;myeditbox_Desc&amp;quot; size=&amp;quot;7&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Standard form field types]]&lt;/div&gt;</summary>
		<author><name>Catanet</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Combo_form_field_type&amp;diff=105918</id>
		<title>Combo form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Combo_form_field_type&amp;diff=105918"/>
		<updated>2013-11-30T11:23:58Z</updated>

		<summary type="html">&lt;p&gt;Catanet: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Provides a combobox field.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the parameter.&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;combobox&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) is the descriptive title of the field.&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) tooltip for the form field.&lt;br /&gt;
* &#039;&#039;&#039;class&#039;&#039;&#039; (optional) specify your own classes for additonal markup, defaults to &amp;quot;combobox&amp;quot;&lt;br /&gt;
* &#039;&#039;&#039;readonly&#039;&#039;&#039; (optiona) set to &amp;quot;true&amp;quot;, defaults to false, meaning editable.&lt;br /&gt;
* &#039;&#039;&#039;disabled&#039;&#039;&#039; (optional) set to &amp;quot;true&amp;quot;, defaults to false, meaning enabled.&lt;br /&gt;
* &#039;&#039;&#039;size&#039;&#039;&#039; (optional) sets the input size of the field&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; (optional) sets whether input is required, defaults to no input required.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;myeditbox&amp;quot; type=&amp;quot;combobox&amp;quot; label=&amp;quot;MyEditBox&amp;quot; description=&amp;quot;myeditbox_Desc&amp;quot; size=&amp;quot;7&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Standard form field types]]&lt;/div&gt;</summary>
		<author><name>Catanet</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=J3.x:Using_the_JToolbar_class_in_the_frontend&amp;diff=104835</id>
		<title>J3.x:Using the JToolbar class in the frontend</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=J3.x:Using_the_JToolbar_class_in_the_frontend&amp;diff=104835"/>
		<updated>2013-11-08T19:40:51Z</updated>

		<summary type="html">&lt;p&gt;Catanet: /* Using JToolBar with Search Engine Friendly enabled (SEF) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{page|needs review}}{{RightTOC}}&lt;br /&gt;
== Using JToolBar ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s now simpler to use JToolBar in the front end than it was in Joomla! 1.5 as it only requires two steps.&lt;br /&gt;
{{clear}}&lt;br /&gt;
===Step 1===&lt;br /&gt;
Using the MVC architecture, add a function definition to view.html.php file in the view you wish to add the toolbar to.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;gt;&lt;br /&gt;
	function getToolbar() {&lt;br /&gt;
		// add required stylesheets from admin template&lt;br /&gt;
		$document    = &amp;amp; JFactory::getDocument();&lt;br /&gt;
		$document-&amp;gt;addStyleSheet(&#039;administrator/templates/system/css/system.css&#039;);&lt;br /&gt;
		//now we add the necessary stylesheets from the administrator template&lt;br /&gt;
		//in this case i make reference to the bluestork default administrator template in joomla 1.6&lt;br /&gt;
		$document-&amp;gt;addCustomTag(&lt;br /&gt;
			&#039;&amp;lt;link href=&amp;quot;administrator/templates/bluestork/css/template.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; /&amp;gt;&#039;.&amp;quot;\n\n&amp;quot;.&lt;br /&gt;
			&#039;&amp;lt;!--[if IE 7]&amp;gt;&#039;.&amp;quot;\n&amp;quot;.&lt;br /&gt;
			&#039;&amp;lt;link href=&amp;quot;administrator/templates/bluestork/css/ie7.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; /&amp;gt;&#039;.&amp;quot;\n&amp;quot;.&lt;br /&gt;
			&#039;&amp;lt;![endif]--&amp;gt;&#039;.&amp;quot;\n&amp;quot;.&lt;br /&gt;
			&#039;&amp;lt;!--[if gte IE 8]&amp;gt;&#039;.&amp;quot;\n\n&amp;quot;.&lt;br /&gt;
			&#039;&amp;lt;link href=&amp;quot;administrator/templates/bluestork/css/ie8.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; /&amp;gt;&#039;.&amp;quot;\n&amp;quot;.&lt;br /&gt;
			&#039;&amp;lt;![endif]--&amp;gt;&#039;.&amp;quot;\n&amp;quot;.&lt;br /&gt;
			&#039;&amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;administrator/templates/bluestork/css/rounded.css&amp;quot; type=&amp;quot;text/css&amp;quot; /&amp;gt;&#039;.&amp;quot;\n&amp;quot;&lt;br /&gt;
			);&lt;br /&gt;
		//load the JToolBar library and create a toolbar&lt;br /&gt;
		jimport(&#039;joomla.html.toolbar&#039;);&lt;br /&gt;
		$bar =&amp;amp; new JToolBar( &#039;toolbar&#039; );&lt;br /&gt;
		//and make whatever calls you require&lt;br /&gt;
		$bar-&amp;gt;appendButton( &#039;Standard&#039;, &#039;save&#039;, &#039;Save&#039;, &#039;savetask&#039;, false );&lt;br /&gt;
		$bar-&amp;gt;appendButton( &#039;Separator&#039; );&lt;br /&gt;
		$bar-&amp;gt;appendButton( &#039;Standard&#039;, &#039;cancel&#039;, &#039;Cancel&#039;, &#039;canceltask&#039;, false );&lt;br /&gt;
		//generate the html and return&lt;br /&gt;
		return $bar-&amp;gt;render();&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 2===&lt;br /&gt;
&lt;br /&gt;
Now in the corresponding tmpl file, you simply need to add code like the following (added here to a default.php file in the tmpl folder of the view to which the code above was added to the view.html.php file.&lt;br /&gt;
Note I say &amp;quot;like&amp;quot; the following, changes may be required. I&#039;m including the &amp;lt;form&amp;gt; declaration html (the toolbar MUST be in a form with the id of &amp;quot;adminForm&amp;quot; in order for it to work.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;index.php&amp;quot; method=&amp;quot;post&amp;quot; id=&amp;quot;adminForm&amp;quot; name=&amp;quot;adminForm&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;?php echo $this-&amp;gt;getToolbar(); ?&amp;gt;&lt;br /&gt;
	&amp;lt;input type = &amp;quot;hidden&amp;quot; name = &amp;quot;task&amp;quot; value = &amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;input type = &amp;quot;hidden&amp;quot; name = &amp;quot;option&amp;quot; value = &amp;quot;com_yourcom&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;clr&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
You&#039;ll note the [div class=&amp;quot;clr&amp;quot;] which you may or may not need depending on your own design requirements. If you don&#039;t add the div tag, slapping this code into an existing component front end will place the buttons to the right and level with the content on the left.&lt;br /&gt;
Also, and as explained above, you&#039;ll need to add functions within the controller that is called when one of the toolbar buttons is pressed, to process the request gracefully.&lt;br /&gt;
&lt;br /&gt;
== Using JToolBar with Search Engine Friendly enabled (SEF)==&lt;br /&gt;
&lt;br /&gt;
When using the toolbar on the frontend,the standard buttons will sometimes bug out. This is usually because Search Engine Friendly urls is defined.&lt;br /&gt;
&lt;br /&gt;
What happens is that instead of going to index.php?option=com_yourcom&amp;amp;view=&amp;amp;...#, it will go to index.php/friendlyurl# . This bugs out many users.&lt;br /&gt;
&lt;br /&gt;
Using these two together can be done,however. There&#039;s two tricks to it. First, make a class called JButtonFrontend and extend JButton. For this, jimport(&#039;joomla.html.toolbar&#039;) has to be done,because this includes the standard button classes.&lt;br /&gt;
&lt;br /&gt;
Just copy over the content of joomla.html.toolbar.button standard.php; then, change the fetchbutton function&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
//Goes inside JButtonFrontend class definition.&lt;br /&gt;
	public function fetchButton($type = &#039;Standard&#039;, $name = &#039;&#039;, $text = &#039;&#039;, $task = &#039;&#039;, $list = true)&lt;br /&gt;
	{&lt;br /&gt;
		$i18n_text = JText::_($text);&lt;br /&gt;
		$class = $this-&amp;gt;fetchIconClass($name);&lt;br /&gt;
		$doTask = $this-&amp;gt;_getCommand($text, $task, $list);&lt;br /&gt;
&lt;br /&gt;
		$html = &amp;quot;&amp;lt;a href=\&amp;quot;javascript: void( $doTask);\&amp;quot; onclick=\&amp;quot;$doTask\&amp;quot; class=\&amp;quot;toolbar\&amp;quot;&amp;gt;\n&amp;quot;;&lt;br /&gt;
		$html .= &amp;quot;&amp;lt;span class=\&amp;quot;$class\&amp;quot;&amp;gt;\n&amp;quot;;&lt;br /&gt;
		$html .= &amp;quot;&amp;lt;/span&amp;gt;\n&amp;quot;;&lt;br /&gt;
		$html .= &amp;quot;$i18n_text\n&amp;quot;;&lt;br /&gt;
		$html .= &amp;quot;&amp;lt;/a&amp;gt;\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		return $html;&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, in your mainfile (site/yourcom.php), use this:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JLoader::register(&#039;JButtonFrontend&#039;, dirname(__FILE__) . &#039;/buttons/frontend.php&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, I made a directory called &#039;buttons&#039;  in my /site directory. If you do so, don&#039;t forget to add it to your package xml file! (yourcom.xml).&lt;br /&gt;
&lt;br /&gt;
You can now use the &#039;Frontend&#039; button:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;bar-&amp;gt;appendButton( &#039;Frontend&#039;, &#039;name&#039;, &#039;label&#039;, &#039;subcontroller.method&#039;, false );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Catanet</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Archived:How_to_add_custom_filters_to_components&amp;diff=84897</id>
		<title>Archived:How to add custom filters to components</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Archived:How_to_add_custom_filters_to_components&amp;diff=84897"/>
		<updated>2013-04-21T01:15:55Z</updated>

		<summary type="html">&lt;p&gt;Catanet: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{version/tutor|1.7,2.5}}{{RightTOC}}&lt;br /&gt;
== Overview ==&lt;br /&gt;
This is a how-to on how to add &#039;&#039;&#039;ordering&#039;&#039;&#039; and &#039;&#039;&#039;filtering&#039;&#039;&#039; (search, custom dropdown, state) to a component backend page.&amp;lt;br/&amp;gt;&lt;br /&gt;
This approach is almost exactly the same for the frontend.&amp;lt;br/&amp;gt;&lt;br /&gt;
In general, the process of adding a &#039;&#039;&#039;custom field filter&#039;&#039;&#039; breaks down into the following steps:&lt;br /&gt;
* Creating the class that will generate the form dropdown options&lt;br /&gt;
* Adapting the view to display the form dropdown input&lt;br /&gt;
* Adapting the model to retrieve data from DB &amp;amp; to set submission values in the Joomla &#039;state&#039;. For a better understanding of the code samples, the db table is called &#039;my_company&#039; and the fields are: id, name, state, company, somefield, someotherfieldtosearchin.&lt;br /&gt;
&lt;br /&gt;
== Extend JFormFieldList (models / fields / fieldname.php) ==&lt;br /&gt;
Frequently your filter fields will be very basic; probably simply a dropdown list of one of the columns being displayed on the current page.  Regardless, you will need to create your own field element.  This really isn&#039;t a big deal - this file will probably be less than 70 lines, including comments.  The code below will generate the dropdown element to filter by companies.  For more information and complex examples on creating this class see [[Creating_a_custom_form_field_type]].&lt;br /&gt;
&lt;br /&gt;
My &#039;companies&#039; dropdown element:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
defined(&#039;JPATH_BASE&#039;) or die;&lt;br /&gt;
&lt;br /&gt;
jimport(&#039;joomla.html.html&#039;);&lt;br /&gt;
jimport(&#039;joomla.form.formfield&#039;);&lt;br /&gt;
jimport(&#039;joomla.form.helper&#039;);&lt;br /&gt;
JFormHelper::loadFieldClass(&#039;list&#039;);&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Custom Field class for the Joomla Framework.&lt;br /&gt;
 *&lt;br /&gt;
 * @package		Joomla.Administrator&lt;br /&gt;
 * @subpackage	        com_my&lt;br /&gt;
 * @since		1.6&lt;br /&gt;
 */&lt;br /&gt;
class JFormFieldMyCompany extends JFormFieldList&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * The form field type.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @var		string&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	protected $type = &#039;MyCompany&#039;;&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to get the field options.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return	array	The field option objects.&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	public function getOptions()&lt;br /&gt;
	{&lt;br /&gt;
		// Initialize variables.&lt;br /&gt;
		$options = array();&lt;br /&gt;
&lt;br /&gt;
		$db	= JFactory::getDbo();&lt;br /&gt;
		$query	= $db-&amp;gt;getQuery(true);&lt;br /&gt;
&lt;br /&gt;
		$query-&amp;gt;select(&#039;id As value, name As text&#039;);&lt;br /&gt;
		$query-&amp;gt;from(&#039;#__my_companies AS a&#039;);&lt;br /&gt;
		$query-&amp;gt;order(&#039;a.name&#039;);&lt;br /&gt;
		$query-&amp;gt;where(&#039;state = 1&#039;);&lt;br /&gt;
&lt;br /&gt;
		// Get the options.&lt;br /&gt;
		$db-&amp;gt;setQuery($query);&lt;br /&gt;
&lt;br /&gt;
		$options = $db-&amp;gt;loadObjectList();&lt;br /&gt;
&lt;br /&gt;
		// Check for a database error.&lt;br /&gt;
		if ($db-&amp;gt;getErrorNum()) {&lt;br /&gt;
			JError::raiseWarning(500, $db-&amp;gt;getErrorMsg());&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		return $options;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Obviously, there is only one section here that needs to be customized: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
		$query-&amp;gt;select(&#039;id As value, name As text&#039;);&lt;br /&gt;
		$query-&amp;gt;from(&#039;#__my_companies AS a&#039;);&lt;br /&gt;
		$query-&amp;gt;order(&#039;a.name&#039;);&lt;br /&gt;
		$query-&amp;gt;where(&#039;state = 1&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the database name and adjust the sql as necessary.  This will produce the text and values for the select element options.  I highly recommend not changing the value and text names.  Although I did not test this theory, it seems likely that ancestor classes are expecting these names as keys in the resulting array.&lt;br /&gt;
&lt;br /&gt;
== Modify Model (models / zzz.php) ==&lt;br /&gt;
In your model you have to include these two functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
//Add this handy array with database fields to search in&lt;br /&gt;
	protected $searchInFields = array(&#039;text&#039;,&#039;a.name&#039;,&#039;someotherfieldtosearchin&#039;);&lt;br /&gt;
&lt;br /&gt;
//Override construct to allow filtering and ordering on our fields&lt;br /&gt;
	public function __construct($config = array()) {&lt;br /&gt;
	 	$config[&#039;filter_fields&#039;]=array_merge($this-&amp;gt;searchInFields,array(&#039;a.company&#039;));&lt;br /&gt;
		parent::__construct($config);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	protected function getListQuery(){&lt;br /&gt;
		$db = JFactory::getDBO();&lt;br /&gt;
		$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
&lt;br /&gt;
                //CHANGE THIS QUERY AS YOU NEED...&lt;br /&gt;
                $query-&amp;gt;select(&#039;id As value, name As text, somefield&#039;)&lt;br /&gt;
			-&amp;gt;from(&#039;#__my_companies AS a&#039;)&lt;br /&gt;
			-&amp;gt;order(	$db-&amp;gt;escape($this-&amp;gt;getState(&#039;list.ordering&#039;, &#039;pa.id&#039;)) . &#039; &#039; .&lt;br /&gt;
					$db-&amp;gt;escape($this-&amp;gt;getState(&#039;list.direction&#039;, &#039;desc&#039;)));&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
		&lt;br /&gt;
		// Filter search // Extra: Search more than one fields and for multiple words&lt;br /&gt;
		$regex = str_replace(&#039; &#039;, &#039;|&#039;, $this-&amp;gt;getState(&#039;filter.search&#039;));&lt;br /&gt;
		if (!empty($regex)) {&lt;br /&gt;
			$regex=&#039; REGEXP &#039;.$db-&amp;gt;quote($regex);&lt;br /&gt;
			$query-&amp;gt;where(&#039;(&#039;.implode($regex.&#039; OR &#039;,$this-&amp;gt;searchInFields).$regex.&#039;)&#039;);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		// Filter company&lt;br /&gt;
		$company= $db-&amp;gt;escape($this-&amp;gt;getState(&#039;filter.company&#039;));&lt;br /&gt;
		if (!empty($company)) {&lt;br /&gt;
			$query-&amp;gt;where(&#039;(a.company=&#039;.$company.&#039;)&#039;);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		// Filter by state (published, trashed, etc.)&lt;br /&gt;
		$state = $db-&amp;gt;escape($this-&amp;gt;getState(&#039;filter.state&#039;));&lt;br /&gt;
		if (is_numeric($state)) {&lt;br /&gt;
			$query-&amp;gt;where(&#039;a.state = &#039; . (int) $state);&lt;br /&gt;
		}&lt;br /&gt;
		elseif ($state === &#039;&#039;) {&lt;br /&gt;
			$query-&amp;gt;where(&#039;(a.state = 0 OR a.state = 1)&#039;);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		//echo $db-&amp;gt;replacePrefix( (string) $query );//debug&lt;br /&gt;
		return $query;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to auto-populate the model state.&lt;br /&gt;
	 *&lt;br /&gt;
	 * Note. Calling getState in this method will result in recursion.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	protected function populateState($ordering = null, $direction = null)&lt;br /&gt;
	{&lt;br /&gt;
		// Initialise variables.&lt;br /&gt;
		$app = JFactory::getApplication(&#039;administrator&#039;);&lt;br /&gt;
	&lt;br /&gt;
		// Load the filter state.&lt;br /&gt;
		$search = $this-&amp;gt;getUserStateFromRequest($this-&amp;gt;context.&#039;.filter.search&#039;, &#039;filter_search&#039;);&lt;br /&gt;
		//Omit double (white-)spaces and set state&lt;br /&gt;
		$this-&amp;gt;setState(&#039;filter.search&#039;, preg_replace(&#039;/\s+/&#039;,&#039; &#039;, $search));&lt;br /&gt;
		&lt;br /&gt;
		//Filter (dropdown) state&lt;br /&gt;
		$state = $this-&amp;gt;getUserStateFromRequest($this-&amp;gt;context.&#039;.filter.state&#039;, &#039;filter_state&#039;, &#039;&#039;, &#039;string&#039;);&lt;br /&gt;
		$this-&amp;gt;setState(&#039;filter.state&#039;, $state);&lt;br /&gt;
&lt;br /&gt;
		//Filter (dropdown) company&lt;br /&gt;
		$state = $this-&amp;gt;getUserStateFromRequest($this-&amp;gt;context.&#039;.filter.company&#039;, &#039;filter_company&#039;, &#039;&#039;, &#039;string&#039;);&lt;br /&gt;
		$this-&amp;gt;setState(&#039;filter.company&#039;, $state);&lt;br /&gt;
	&lt;br /&gt;
		//Takes care of states: list. limit / start / ordering / direction&lt;br /&gt;
		parent::populateState(&#039;a.name&#039;, &#039;asc&#039;);&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;For the frontend:&#039;&#039;&#039; your &#039;&#039;$app&#039;&#039; variable looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  protected function populateState($ordering = null, $direction = null)&lt;br /&gt;
        {&lt;br /&gt;
                // Initialise variables.&lt;br /&gt;
                $app = JFactory::getApplication();&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Modify View (views / zzz / view.html.php) ==&lt;br /&gt;
In you view class, you have to set the state, like this:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;gt;&lt;br /&gt;
		$this-&amp;gt;items		= $this-&amp;gt;get(&#039;Items&#039;);&lt;br /&gt;
		$this-&amp;gt;pagination	= $this-&amp;gt;get(&#039;Pagination&#039;);&lt;br /&gt;
		$this-&amp;gt;state		= $this-&amp;gt;get(&#039;State&#039;);&lt;br /&gt;
&lt;br /&gt;
		//Following variables used more than once&lt;br /&gt;
		$this-&amp;gt;sortColumn 	= $this-&amp;gt;state-&amp;gt;get(&#039;list.ordering&#039;);&lt;br /&gt;
		$this-&amp;gt;sortDirection	= $this-&amp;gt;state-&amp;gt;get(&#039;list.direction&#039;);&lt;br /&gt;
		$this-&amp;gt;searchterms	= $this-&amp;gt;state-&amp;gt;get(&#039;filter.search&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Modify Template (views / zzz / tmpl / default.php) ==&lt;br /&gt;
=== Basic ===&lt;br /&gt;
Top of template somewhere:&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
//Get companie options&lt;br /&gt;
JFormHelper::addFieldPath(JPATH_COMPONENT . &#039;/models/fields&#039;);&lt;br /&gt;
$companies = JFormHelper::loadFieldType(&#039;MyCompany&#039;, false);&lt;br /&gt;
$companyOptions=$companies-&amp;gt;getOptions(); // works only if you set your field getOptions on public!!&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
In your template file, this fieldset reflects filter options:&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;fieldset id=&amp;quot;filter-bar&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;div class=&amp;quot;filter-search fltlft&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;filter_search&amp;quot; id=&amp;quot;filter_search&amp;quot; value=&amp;quot;&amp;lt;?php echo $this-&amp;gt;escape($this-&amp;gt;searchterms); ?&amp;gt;&amp;quot; title=&amp;quot;&amp;lt;?php echo JText::_(&#039;Search in company, etc.&#039;); ?&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;button type=&amp;quot;submit&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;?php echo JText::_(&#039;JSEARCH_FILTER_SUBMIT&#039;); ?&amp;gt;&lt;br /&gt;
			&amp;lt;/button&amp;gt;&lt;br /&gt;
			&amp;lt;button type=&amp;quot;button&amp;quot; onclick=&amp;quot;document.id(&#039;filter_search&#039;).value=&#039;&#039;;this.form.submit();&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;?php echo JText::_(&#039;JSEARCH_FILTER_CLEAR&#039;); ?&amp;gt;&lt;br /&gt;
			&amp;lt;/button&amp;gt;&lt;br /&gt;
		&amp;lt;/div&amp;gt;&lt;br /&gt;
		&amp;lt;div class=&amp;quot;filter-select fltrt&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;select name=&amp;quot;filter_state&amp;quot; class=&amp;quot;inputbox&amp;quot; onchange=&amp;quot;this.form.submit()&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;option value=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
					&amp;lt;?php echo JText::_(&#039;JOPTION_SELECT_PUBLISHED&#039;);?&amp;gt;&lt;br /&gt;
				&amp;lt;/option&amp;gt;&lt;br /&gt;
				&amp;lt;?php echo JHtml::_(&#039;select.options&#039;, JHtml::_(&#039;jgrid.publishedOptions&#039;, array(&#039;archived&#039;=&amp;gt;false)), &#039;value&#039;, &#039;text&#039;, $this-&amp;gt;state-&amp;gt;get(&#039;filter.state&#039;), true);?&amp;gt;&lt;br /&gt;
			&amp;lt;/select&amp;gt;&lt;br /&gt;
			&lt;br /&gt;
			&amp;lt;select name=&amp;quot;filter_type&amp;quot; class=&amp;quot;inputbox&amp;quot; onchange=&amp;quot;this.form.submit()&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;option value=&amp;quot;&amp;quot;&amp;gt; - Select Company - &amp;lt;/option&amp;gt;&lt;br /&gt;
				&amp;lt;?php echo JHtml::_(&#039;select.options&#039;, $companyOptions, &#039;value&#039;, &#039;text&#039;, $this-&amp;gt;state-&amp;gt;get(&#039;filter.company&#039;));?&amp;gt;&lt;br /&gt;
			&amp;lt;/select&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;/div&amp;gt;&lt;br /&gt;
	&amp;lt;/fieldset&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Remark&#039;&#039;&#039;: the name of the &#039;&#039;select&#039;&#039; tag must be the same as defined in the &#039;&#039;populateState&#039;&#039; function. In the example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source php&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    //populateState function&lt;br /&gt;
    $state = $this-&amp;gt;getUserStateFromRequest($this-&amp;gt;context.&#039;.filter.state&#039;, &#039;filter_state&#039;, &#039;&#039;, &#039;string&#039;);&lt;br /&gt;
&lt;br /&gt;
    //template&lt;br /&gt;
    &amp;lt;select name=&amp;quot;filter_state&amp;quot; class=&amp;quot;inputbox&amp;quot; onchange=&amp;quot;this.form.submit()&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Extra: highlighting search terms ===&lt;br /&gt;
Here is some extra to visually mark the found search terms in the results page.&amp;lt;br/&amp;gt;&lt;br /&gt;
==== Template ====&lt;br /&gt;
&amp;lt;u&amp;gt;Add this somewhere at top somehwere:&amp;lt;/u&amp;gt; &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$searchterms = $this-&amp;gt;state-&amp;gt;get(&#039;filter.search&#039;);&lt;br /&gt;
&lt;br /&gt;
//Highlight search terms with js (if we did a search =&amp;gt; more performant and otherwise crash)&lt;br /&gt;
if (strlen($searchterms)&amp;gt;1) JHtml::_(&#039;behavior.highlighter&#039;, explode(&#039; &#039;,$searchterms));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And further in your template, enclose the specific fields with the default highlighter finder.&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;u&amp;gt;Example:&amp;lt;/u&amp;gt;&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;highlighter-start&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
	&amp;lt;table class=&amp;quot;adminlist&amp;quot;&amp;gt;&lt;br /&gt;
	...&lt;br /&gt;
	&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;highlighter-end&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
==== CSS ====&lt;br /&gt;
If your default admin template doesn&#039;t have required css, you should add the class in your component css.&lt;br /&gt;
&amp;lt;u&amp;gt;Example in controller:&amp;lt;/u&amp;gt;&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JHtml::stylesheet(&#039;com_peopleactions/admin.css&#039;, array(), true);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;u&amp;gt;In admin.css:&amp;lt;/u&amp;gt;&amp;lt;source lang=&amp;quot;css&amp;quot;&amp;gt;&lt;br /&gt;
.highlight {   background: none repeat scroll 0 0 #FFFF00; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
[[User:riledhel|Javier Constanzo]]&lt;br /&gt;
&lt;br /&gt;
[[User:Doub1ejack|Doub1ejack]]&lt;br /&gt;
&lt;br /&gt;
[[User:E-builds|E-builds]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Component Development]]&lt;br /&gt;
[[Category:Tutorials]]&lt;br /&gt;
[[Category:Joomla! 1.6]]&lt;br /&gt;
[[Category:Joomla! 1.7]]&lt;br /&gt;
[[Category:Joomla! 2.5]]&lt;/div&gt;</summary>
		<author><name>Catanet</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Portal:Component_Development/Reading_list&amp;diff=84886</id>
		<title>Portal:Component Development/Reading list</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Portal:Component_Development/Reading_list&amp;diff=84886"/>
		<updated>2013-04-21T00:57:14Z</updated>

		<summary type="html">&lt;p&gt;Catanet: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[Portal:Platform|Joomla Platform Portal]] {{JVer|platform}}&lt;br /&gt;
* [[File Structure and Naming Conventions]] {{JVer/multi|1.5,2.5,3.0}}&lt;br /&gt;
* [[Component Program Flow]]. UML sequence diagrams showing the control flow for a component. {{JVer/multi|1.5,2.5,3.0}}&lt;br /&gt;
* [[Developing a Model-View-Controller Component]] {{JVer/multi|1.5,2.5,3.0}}&lt;br /&gt;
* [[Components:xml installfile]].  An example component XML installation file. {{JVer|1.5}}&lt;br /&gt;
* [[Manifest files]] for the installation of extensions {{JVer/multi|1.6,1.7,2.5,3.0}}&lt;br /&gt;
* [[Adding sortable columns to a table in a component]]&lt;br /&gt;
* [[How to add custom filters to components]] {{JVer/multi|1.7,2.5}}&lt;br /&gt;
* [[Supporting SEF URLs in your component]]&lt;br /&gt;
* [[Supporting plugins in your component]] {{JVer|1.5}}&lt;br /&gt;
* [[Using JPagination in your component]]&lt;br /&gt;
* [[Using the JPane classes in a component]] {{JVer|1.5}}&lt;br /&gt;
* [[Using the JHtmlTabs class in a component]] {{JVer/multi|1.6,1.7,2.5,3.0}}&lt;br /&gt;
* [[Using the editor in a component]]&lt;br /&gt;
* [[Adding AJAX to your component]]&lt;br /&gt;
* [[Ajax using MooTools]]&lt;br /&gt;
* [[How to add breadcrumbs]]&lt;br /&gt;
* [[Sending email from extensions]]&lt;br /&gt;
* [[Using the JToolBar class in the frontend]]&lt;br /&gt;
* [[Creating a toolbar for your component]]&lt;br /&gt;
* [[Creating a file uploader in your component]]&lt;br /&gt;
* [[Adding Javascript moo.fx to your component]]&lt;br /&gt;
* [[Creating Mootools accordion or simple slider/toggler]]&lt;br /&gt;
* [[Adding view layout configuration parameters]]&lt;br /&gt;
* [[Using a custom image in the menu bar title]]&lt;br /&gt;
* [[How to implement XML-RPC in a component]]&lt;br /&gt;
* [[Using multiple models in an MVC component]]&lt;br /&gt;
* [[Adding ACL rules to your component]] {{JVer/multi|1.6,1.7,2.5,3.0}}&lt;br /&gt;
* [[JController and its subclass usage overview]] {{JVer/multi|1.6,1.7,2.5}}&lt;br /&gt;
* [[Managing Component Updates with Joomla!2.5 - Part 1]] {{JVer/multi|1.6,1.7,2.5}}&lt;br /&gt;
* [[Xml-rpc changes in Joomla! 1.6]] {{JVer/multi|1.6,1.7,2.5,3.0}}&lt;br /&gt;
* [[Creating PDF views]] {{JVer|2.5}}&amp;lt;noinclude&amp;gt;[[Category:Landing subpages|{{PAGENAME}}]]&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Catanet</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Archived:How_to_add_custom_filters_to_components&amp;diff=84881</id>
		<title>Archived:How to add custom filters to components</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Archived:How_to_add_custom_filters_to_components&amp;diff=84881"/>
		<updated>2013-04-21T00:46:36Z</updated>

		<summary type="html">&lt;p&gt;Catanet: /* Basic */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{version/tutor|1.7,2.5}}{{RightTOC}}&lt;br /&gt;
== Overview ==&lt;br /&gt;
This is a how-to on how to add &#039;&#039;&#039;ordering&#039;&#039;&#039; and &#039;&#039;&#039;filtering&#039;&#039;&#039; (search, custom dropdown, state) to a component backend page.&amp;lt;br/&amp;gt;&lt;br /&gt;
This approach is almost exactly the same for the frontend.&amp;lt;br/&amp;gt;&lt;br /&gt;
In general, the process of adding a &#039;&#039;&#039;custom field filter&#039;&#039;&#039; breaks down into the following steps:&lt;br /&gt;
* Creating the class that will generate the form dropdown options&lt;br /&gt;
* Adapting the view to display the form dropdown input&lt;br /&gt;
* Adapting the model to retrieve data from DB &amp;amp; to set submission values in the Joomla &#039;state&#039;. For a better understanding of the code samples, the db table is called &#039;my_company&#039; and the fields are: id, name, state, company, somefield, someotherfieldtosearchin.&lt;br /&gt;
&lt;br /&gt;
== Extend JFormFieldList (models / fields / fieldname.php) ==&lt;br /&gt;
Frequently your filter fields will be very basic; probably simply a dropdown list of one of the columns being displayed on the current page.  Regardless, you will need to create your own field element.  This really isn&#039;t a big deal - this file will probably be less than 70 lines, including comments.  The code below will generate the dropdown element to filter by companies.  For more information and complex examples on creating this class see [[Creating_a_custom_form_field_type]].&lt;br /&gt;
&lt;br /&gt;
My &#039;companies&#039; dropdown element:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
defined(&#039;JPATH_BASE&#039;) or die;&lt;br /&gt;
&lt;br /&gt;
jimport(&#039;joomla.html.html&#039;);&lt;br /&gt;
jimport(&#039;joomla.form.formfield&#039;);&lt;br /&gt;
jimport(&#039;joomla.form.helper&#039;);&lt;br /&gt;
JFormHelper::loadFieldClass(&#039;list&#039;);&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Custom Field class for the Joomla Framework.&lt;br /&gt;
 *&lt;br /&gt;
 * @package		Joomla.Administrator&lt;br /&gt;
 * @subpackage	        com_my&lt;br /&gt;
 * @since		1.6&lt;br /&gt;
 */&lt;br /&gt;
class JFormFieldMyCompany extends JFormFieldList&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * The form field type.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @var		string&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	protected $type = &#039;MyCompany&#039;;&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to get the field options.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return	array	The field option objects.&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	public function getOptions()&lt;br /&gt;
	{&lt;br /&gt;
		// Initialize variables.&lt;br /&gt;
		$options = array();&lt;br /&gt;
&lt;br /&gt;
		$db	= JFactory::getDbo();&lt;br /&gt;
		$query	= $db-&amp;gt;getQuery(true);&lt;br /&gt;
&lt;br /&gt;
		$query-&amp;gt;select(&#039;id As value, name As text&#039;);&lt;br /&gt;
		$query-&amp;gt;from(&#039;#__my_companies AS a&#039;);&lt;br /&gt;
		$query-&amp;gt;order(&#039;a.name&#039;);&lt;br /&gt;
		$query-&amp;gt;where(&#039;state = 1&#039;);&lt;br /&gt;
&lt;br /&gt;
		// Get the options.&lt;br /&gt;
		$db-&amp;gt;setQuery($query);&lt;br /&gt;
&lt;br /&gt;
		$options = $db-&amp;gt;loadObjectList();&lt;br /&gt;
&lt;br /&gt;
		// Check for a database error.&lt;br /&gt;
		if ($db-&amp;gt;getErrorNum()) {&lt;br /&gt;
			JError::raiseWarning(500, $db-&amp;gt;getErrorMsg());&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		return $options;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Obviously, there is only one section here that needs to be customized: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
		$query-&amp;gt;select(&#039;id As value, name As text&#039;);&lt;br /&gt;
		$query-&amp;gt;from(&#039;#__my_companies AS a&#039;);&lt;br /&gt;
		$query-&amp;gt;order(&#039;a.name&#039;);&lt;br /&gt;
		$query-&amp;gt;where(&#039;state = 1&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the database name and adjust the sql as necessary.  This will produce the text and values for the select element options.  I highly recommend not changing the value and text names.  Although I did not test this theory, it seems likely that ancestor classes are expecting these names as keys in the resulting array.&lt;br /&gt;
&lt;br /&gt;
== Modify Model (models / zzz.php) ==&lt;br /&gt;
In your model you have to include these two functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
//Add this handy array with database fields to search in&lt;br /&gt;
	protected $searchInFields = array(&#039;text&#039;,&#039;a.name&#039;,&#039;someotherfieldtosearchin&#039;);&lt;br /&gt;
&lt;br /&gt;
//Override construct to allow filtering and ordering on our fields&lt;br /&gt;
	public function __construct($config = array()) {&lt;br /&gt;
	 	$config[&#039;filter_fields&#039;]=array_merge($this-&amp;gt;searchInFields,array(&#039;a.company&#039;));&lt;br /&gt;
		parent::__construct($config);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	protected function getListQuery(){&lt;br /&gt;
		$db = JFactory::getDBO();&lt;br /&gt;
		$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
&lt;br /&gt;
                //CHANGE THIS QUERY AS YOU NEED...&lt;br /&gt;
                $query-&amp;gt;select(&#039;id As value, name As text, somefield&#039;)&lt;br /&gt;
			-&amp;gt;from(&#039;#__my_companies AS a&#039;)&lt;br /&gt;
			-&amp;gt;order(	$db-&amp;gt;escape($this-&amp;gt;getState(&#039;list.ordering&#039;, &#039;pa.id&#039;)) . &#039; &#039; .&lt;br /&gt;
					$db-&amp;gt;escape($this-&amp;gt;getState(&#039;list.direction&#039;, &#039;desc&#039;)));&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
		&lt;br /&gt;
		// Filter search // Extra: Search more than one fields and for multiple words&lt;br /&gt;
		$regex = str_replace(&#039; &#039;, &#039;|&#039;, $this-&amp;gt;getState(&#039;filter.search&#039;));&lt;br /&gt;
		if (!empty($regex)) {&lt;br /&gt;
			$regex=&#039; REGEXP &#039;.$db-&amp;gt;quote($regex);&lt;br /&gt;
			$query-&amp;gt;where(&#039;(&#039;.implode($regex.&#039; OR &#039;,$this-&amp;gt;searchInFields).$regex.&#039;)&#039;);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		// Filter company&lt;br /&gt;
		$company= $db-&amp;gt;escape($this-&amp;gt;getState(&#039;filter.company&#039;));&lt;br /&gt;
		if (!empty($company)) {&lt;br /&gt;
			$query-&amp;gt;where(&#039;(a.company=&#039;.$company.&#039;)&#039;);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		// Filter by state (published, trashed, etc.)&lt;br /&gt;
		$state = $db-&amp;gt;escape($this-&amp;gt;getState(&#039;filter.state&#039;));&lt;br /&gt;
		if (is_numeric($state)) {&lt;br /&gt;
			$query-&amp;gt;where(&#039;a.state = &#039; . (int) $state);&lt;br /&gt;
		}&lt;br /&gt;
		elseif ($state === &#039;&#039;) {&lt;br /&gt;
			$query-&amp;gt;where(&#039;(a.state = 0 OR a.state = 1)&#039;);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		//echo $db-&amp;gt;replacePrefix( (string) $query );//debug&lt;br /&gt;
		return $query;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to auto-populate the model state.&lt;br /&gt;
	 *&lt;br /&gt;
	 * Note. Calling getState in this method will result in recursion.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	protected function populateState($ordering = null, $direction = null)&lt;br /&gt;
	{&lt;br /&gt;
		// Initialise variables.&lt;br /&gt;
		$app = JFactory::getApplication(&#039;administrator&#039;);&lt;br /&gt;
	&lt;br /&gt;
		// Load the filter state.&lt;br /&gt;
		$search = $this-&amp;gt;getUserStateFromRequest($this-&amp;gt;context.&#039;.filter.search&#039;, &#039;filter_search&#039;);&lt;br /&gt;
		//Omit double (white-)spaces and set state&lt;br /&gt;
		$this-&amp;gt;setState(&#039;filter.search&#039;, preg_replace(&#039;/\s+/&#039;,&#039; &#039;, $search));&lt;br /&gt;
		&lt;br /&gt;
		//Filter (dropdown) state&lt;br /&gt;
		$state = $this-&amp;gt;getUserStateFromRequest($this-&amp;gt;context.&#039;.filter.state&#039;, &#039;filter_state&#039;, &#039;&#039;, &#039;string&#039;);&lt;br /&gt;
		$this-&amp;gt;setState(&#039;filter.state&#039;, $state);&lt;br /&gt;
&lt;br /&gt;
		//Filter (dropdown) company&lt;br /&gt;
		$state = $this-&amp;gt;getUserStateFromRequest($this-&amp;gt;context.&#039;.filter.company&#039;, &#039;filter_company&#039;, &#039;&#039;, &#039;string&#039;);&lt;br /&gt;
		$this-&amp;gt;setState(&#039;filter.company&#039;, $state);&lt;br /&gt;
	&lt;br /&gt;
		//Takes care of states: list. limit / start / ordering / direction&lt;br /&gt;
		parent::populateState(&#039;a.name&#039;, &#039;asc&#039;);&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR THE FRONTEND:&#039;&#039;&#039; your &#039;&#039;&#039;$app&#039;&#039;&#039; variable looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  protected function populateState($ordering = null, $direction = null)&lt;br /&gt;
        {&lt;br /&gt;
                // Initialise variables.&lt;br /&gt;
                $app = JFactory::getApplication();&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Modify View (views / zzz / view.html.php) ==&lt;br /&gt;
In you view class, you have to set the state, like this:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;gt;&lt;br /&gt;
		$this-&amp;gt;items		= $this-&amp;gt;get(&#039;Items&#039;);&lt;br /&gt;
		$this-&amp;gt;pagination	= $this-&amp;gt;get(&#039;Pagination&#039;);&lt;br /&gt;
		$this-&amp;gt;state		= $this-&amp;gt;get(&#039;State&#039;);&lt;br /&gt;
&lt;br /&gt;
		//Following variables used more than once&lt;br /&gt;
		$this-&amp;gt;sortColumn 	= $this-&amp;gt;state-&amp;gt;get(&#039;list.ordering&#039;);&lt;br /&gt;
		$this-&amp;gt;sortDirection	= $this-&amp;gt;state-&amp;gt;get(&#039;list.direction&#039;);&lt;br /&gt;
		$this-&amp;gt;searchterms	= $this-&amp;gt;state-&amp;gt;get(&#039;filter.search&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Modify Template (views / zzz / tmpl / default.php) ==&lt;br /&gt;
=== Basic ===&lt;br /&gt;
Top of template somewhere:&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
//Get companie options&lt;br /&gt;
JFormHelper::addFieldPath(JPATH_COMPONENT . &#039;/models/fields&#039;);&lt;br /&gt;
$companies = JFormHelper::loadFieldType(&#039;MyCompany&#039;, false);&lt;br /&gt;
$companyOptions=$companies-&amp;gt;getOptions(); // works only if you set your field getOptions on public!!&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
In your template file, this fieldset reflects filter options:&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;fieldset id=&amp;quot;filter-bar&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;div class=&amp;quot;filter-search fltlft&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;filter_search&amp;quot; id=&amp;quot;filter_search&amp;quot; value=&amp;quot;&amp;lt;?php echo $this-&amp;gt;escape($this-&amp;gt;searchterms); ?&amp;gt;&amp;quot; title=&amp;quot;&amp;lt;?php echo JText::_(&#039;Search in company, etc.&#039;); ?&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;button type=&amp;quot;submit&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;?php echo JText::_(&#039;JSEARCH_FILTER_SUBMIT&#039;); ?&amp;gt;&lt;br /&gt;
			&amp;lt;/button&amp;gt;&lt;br /&gt;
			&amp;lt;button type=&amp;quot;button&amp;quot; onclick=&amp;quot;document.id(&#039;filter_search&#039;).value=&#039;&#039;;this.form.submit();&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;?php echo JText::_(&#039;JSEARCH_FILTER_CLEAR&#039;); ?&amp;gt;&lt;br /&gt;
			&amp;lt;/button&amp;gt;&lt;br /&gt;
		&amp;lt;/div&amp;gt;&lt;br /&gt;
		&amp;lt;div class=&amp;quot;filter-select fltrt&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;select name=&amp;quot;filter_state&amp;quot; class=&amp;quot;inputbox&amp;quot; onchange=&amp;quot;this.form.submit()&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;option value=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
					&amp;lt;?php echo JText::_(&#039;JOPTION_SELECT_PUBLISHED&#039;);?&amp;gt;&lt;br /&gt;
				&amp;lt;/option&amp;gt;&lt;br /&gt;
				&amp;lt;?php echo JHtml::_(&#039;select.options&#039;, JHtml::_(&#039;jgrid.publishedOptions&#039;, array(&#039;archived&#039;=&amp;gt;false)), &#039;value&#039;, &#039;text&#039;, $this-&amp;gt;state-&amp;gt;get(&#039;filter.state&#039;), true);?&amp;gt;&lt;br /&gt;
			&amp;lt;/select&amp;gt;&lt;br /&gt;
			&lt;br /&gt;
			&amp;lt;select name=&amp;quot;filter_type&amp;quot; class=&amp;quot;inputbox&amp;quot; onchange=&amp;quot;this.form.submit()&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;option value=&amp;quot;&amp;quot;&amp;gt; - Select Company - &amp;lt;/option&amp;gt;&lt;br /&gt;
				&amp;lt;?php echo JHtml::_(&#039;select.options&#039;, $companyOptions, &#039;value&#039;, &#039;text&#039;, $this-&amp;gt;state-&amp;gt;get(&#039;filter.company&#039;));?&amp;gt;&lt;br /&gt;
			&amp;lt;/select&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;/div&amp;gt;&lt;br /&gt;
	&amp;lt;/fieldset&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;REMARK&#039;&#039;&#039;: the name of the &#039;&#039;select&#039;&#039; tag must be the same as defined in the &#039;&#039;populateState&#039;&#039; function. In the example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source php&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    //populateState function&lt;br /&gt;
    $state = $this-&amp;gt;getUserStateFromRequest($this-&amp;gt;context.&#039;.filter.state&#039;, &#039;filter_state&#039;, &#039;&#039;, &#039;string&#039;);&lt;br /&gt;
&lt;br /&gt;
    //template&lt;br /&gt;
    &amp;lt;select name=&amp;quot;filter_state&amp;quot; class=&amp;quot;inputbox&amp;quot; onchange=&amp;quot;this.form.submit()&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Extra: highlighting search terms ===&lt;br /&gt;
Here is some extra to visually mark the found search terms in the results page.&amp;lt;br/&amp;gt;&lt;br /&gt;
==== Template ====&lt;br /&gt;
&amp;lt;u&amp;gt;Add this somewhere at top somehwere:&amp;lt;/u&amp;gt; &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$searchterms = $this-&amp;gt;state-&amp;gt;get(&#039;filter.search&#039;);&lt;br /&gt;
&lt;br /&gt;
//Highlight search terms with js (if we did a search =&amp;gt; more performant and otherwise crash)&lt;br /&gt;
if (strlen($searchterms)&amp;gt;1) JHtml::_(&#039;behavior.highlighter&#039;, explode(&#039; &#039;,$searchterms));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And further in your template, enclose the specific fields with the default highlighter finder.&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;u&amp;gt;Example:&amp;lt;/u&amp;gt;&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;highlighter-start&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
	&amp;lt;table class=&amp;quot;adminlist&amp;quot;&amp;gt;&lt;br /&gt;
	...&lt;br /&gt;
	&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;highlighter-end&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
==== CSS ====&lt;br /&gt;
If your default admin template doesn&#039;t have required css, you should add the class in your component css.&lt;br /&gt;
&amp;lt;u&amp;gt;Example in controller:&amp;lt;/u&amp;gt;&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JHtml::stylesheet(&#039;com_peopleactions/admin.css&#039;, array(), true);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;u&amp;gt;In admin.css:&amp;lt;/u&amp;gt;&amp;lt;source lang=&amp;quot;css&amp;quot;&amp;gt;&lt;br /&gt;
.highlight {   background: none repeat scroll 0 0 #FFFF00; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
[[User:riledhel|Javier Constanzo]]&lt;br /&gt;
&lt;br /&gt;
[[User:Doub1ejack|Doub1ejack]]&lt;br /&gt;
&lt;br /&gt;
[[User:E-builds|E-builds]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Component Development]]&lt;br /&gt;
[[Category:Tutorials]]&lt;br /&gt;
[[Category:Joomla! 1.6]]&lt;br /&gt;
[[Category:Joomla! 1.7]]&lt;br /&gt;
[[Category:Joomla! 2.5]]&lt;/div&gt;</summary>
		<author><name>Catanet</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Archived:How_to_add_custom_filters_to_components&amp;diff=84868</id>
		<title>Archived:How to add custom filters to components</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Archived:How_to_add_custom_filters_to_components&amp;diff=84868"/>
		<updated>2013-04-21T00:25:38Z</updated>

		<summary type="html">&lt;p&gt;Catanet: /* Modify Model (models / zzz.php) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{version/tutor|1.7,2.5}}{{RightTOC}}&lt;br /&gt;
== Overview ==&lt;br /&gt;
This is a how-to on how to add &#039;&#039;&#039;ordering&#039;&#039;&#039; and &#039;&#039;&#039;filtering&#039;&#039;&#039; (search, custom dropdown, state) to a component backend page.&amp;lt;br/&amp;gt;&lt;br /&gt;
This approach is almost exactly the same for the frontend.&amp;lt;br/&amp;gt;&lt;br /&gt;
{{notice|Is confirmed: it works also for the frontend. Article&#039;s title need to be changed and redirected.}} &lt;br /&gt;
&lt;br /&gt;
In general, the process of adding a &#039;&#039;&#039;custom field filter&#039;&#039;&#039; breaks down into the following steps:&lt;br /&gt;
* Creating the class that will generate the form dropdown options&lt;br /&gt;
* Adapting the view to display the form dropdown input&lt;br /&gt;
* Adapting the model to retrieve data from DB &amp;amp; to set submission values in the Joomla &#039;state&#039;. For a better understanding of the code samples, the db table is called &#039;my_company&#039; and the fields are: id, name, state, company, somefield, someotherfieldtosearchin.&lt;br /&gt;
&lt;br /&gt;
== Extend JFormFieldList (models / fields / fieldname.php) ==&lt;br /&gt;
Frequently your filter fields will be very basic; probably simply a dropdown list of one of the columns being displayed on the current page.  Regardless, you will need to create your own field element.  This really isn&#039;t a big deal - this file will probably be less than 70 lines, including comments.  The code below will generate the dropdown element to filter by companies.  For more information and complex examples on creating this class see [[Creating_a_custom_form_field_type]].&lt;br /&gt;
&lt;br /&gt;
My &#039;companies&#039; dropdown element:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
defined(&#039;JPATH_BASE&#039;) or die;&lt;br /&gt;
&lt;br /&gt;
jimport(&#039;joomla.html.html&#039;);&lt;br /&gt;
jimport(&#039;joomla.form.formfield&#039;);&lt;br /&gt;
jimport(&#039;joomla.form.helper&#039;);&lt;br /&gt;
JFormHelper::loadFieldClass(&#039;list&#039;);&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Custom Field class for the Joomla Framework.&lt;br /&gt;
 *&lt;br /&gt;
 * @package		Joomla.Administrator&lt;br /&gt;
 * @subpackage	        com_my&lt;br /&gt;
 * @since		1.6&lt;br /&gt;
 */&lt;br /&gt;
class JFormFieldMyCompany extends JFormFieldList&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * The form field type.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @var		string&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	protected $type = &#039;MyCompany&#039;;&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to get the field options.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return	array	The field option objects.&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	public function getOptions()&lt;br /&gt;
	{&lt;br /&gt;
		// Initialize variables.&lt;br /&gt;
		$options = array();&lt;br /&gt;
&lt;br /&gt;
		$db	= JFactory::getDbo();&lt;br /&gt;
		$query	= $db-&amp;gt;getQuery(true);&lt;br /&gt;
&lt;br /&gt;
		$query-&amp;gt;select(&#039;id As value, name As text&#039;);&lt;br /&gt;
		$query-&amp;gt;from(&#039;#__my_companies AS a&#039;);&lt;br /&gt;
		$query-&amp;gt;order(&#039;a.name&#039;);&lt;br /&gt;
		$query-&amp;gt;where(&#039;state = 1&#039;);&lt;br /&gt;
&lt;br /&gt;
		// Get the options.&lt;br /&gt;
		$db-&amp;gt;setQuery($query);&lt;br /&gt;
&lt;br /&gt;
		$options = $db-&amp;gt;loadObjectList();&lt;br /&gt;
&lt;br /&gt;
		// Check for a database error.&lt;br /&gt;
		if ($db-&amp;gt;getErrorNum()) {&lt;br /&gt;
			JError::raiseWarning(500, $db-&amp;gt;getErrorMsg());&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		return $options;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Obviously, there is only one section here that needs to be customized: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
		$query-&amp;gt;select(&#039;id As value, name As text&#039;);&lt;br /&gt;
		$query-&amp;gt;from(&#039;#__my_companies AS a&#039;);&lt;br /&gt;
		$query-&amp;gt;order(&#039;a.name&#039;);&lt;br /&gt;
		$query-&amp;gt;where(&#039;state = 1&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the database name and adjust the sql as necessary.  This will produce the text and values for the select element options.  I highly recommend not changing the value and text names.  Although I did not test this theory, it seems likely that ancestor classes are expecting these names as keys in the resulting array.&lt;br /&gt;
&lt;br /&gt;
== Modify Model (models / zzz.php) ==&lt;br /&gt;
In your model you have to include these two functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
//Add this handy array with database fields to search in&lt;br /&gt;
	protected $searchInFields = array(&#039;text&#039;,&#039;a.name&#039;,&#039;someotherfieldtosearchin&#039;);&lt;br /&gt;
&lt;br /&gt;
//Override construct to allow filtering and ordering on our fields&lt;br /&gt;
	public function __construct($config = array()) {&lt;br /&gt;
	 	$config[&#039;filter_fields&#039;]=array_merge($this-&amp;gt;searchInFields,array(&#039;a.company&#039;));&lt;br /&gt;
		parent::__construct($config);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	protected function getListQuery(){&lt;br /&gt;
		$db = JFactory::getDBO();&lt;br /&gt;
		$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
&lt;br /&gt;
                //CHANGE THIS QUERY AS YOU NEED...&lt;br /&gt;
                $query-&amp;gt;select(&#039;id As value, name As text, somefield&#039;)&lt;br /&gt;
			-&amp;gt;from(&#039;#__my_companies AS a&#039;)&lt;br /&gt;
			-&amp;gt;order(	$db-&amp;gt;escape($this-&amp;gt;getState(&#039;list.ordering&#039;, &#039;pa.id&#039;)) . &#039; &#039; .&lt;br /&gt;
					$db-&amp;gt;escape($this-&amp;gt;getState(&#039;list.direction&#039;, &#039;desc&#039;)));&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
		&lt;br /&gt;
		// Filter search // Extra: Search more than one fields and for multiple words&lt;br /&gt;
		$regex = str_replace(&#039; &#039;, &#039;|&#039;, $this-&amp;gt;getState(&#039;filter.search&#039;));&lt;br /&gt;
		if (!empty($regex)) {&lt;br /&gt;
			$regex=&#039; REGEXP &#039;.$db-&amp;gt;quote($regex);&lt;br /&gt;
			$query-&amp;gt;where(&#039;(&#039;.implode($regex.&#039; OR &#039;,$this-&amp;gt;searchInFields).$regex.&#039;)&#039;);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		// Filter company&lt;br /&gt;
		$company= $db-&amp;gt;escape($this-&amp;gt;getState(&#039;filter.company&#039;));&lt;br /&gt;
		if (!empty($company)) {&lt;br /&gt;
			$query-&amp;gt;where(&#039;(a.company=&#039;.$company.&#039;)&#039;);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		// Filter by state (published, trashed, etc.)&lt;br /&gt;
		$state = $db-&amp;gt;escape($this-&amp;gt;getState(&#039;filter.state&#039;));&lt;br /&gt;
		if (is_numeric($state)) {&lt;br /&gt;
			$query-&amp;gt;where(&#039;a.state = &#039; . (int) $state);&lt;br /&gt;
		}&lt;br /&gt;
		elseif ($state === &#039;&#039;) {&lt;br /&gt;
			$query-&amp;gt;where(&#039;(a.state = 0 OR a.state = 1)&#039;);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		//echo $db-&amp;gt;replacePrefix( (string) $query );//debug&lt;br /&gt;
		return $query;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to auto-populate the model state.&lt;br /&gt;
	 *&lt;br /&gt;
	 * Note. Calling getState in this method will result in recursion.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	protected function populateState($ordering = null, $direction = null)&lt;br /&gt;
	{&lt;br /&gt;
		// Initialise variables.&lt;br /&gt;
		$app = JFactory::getApplication(&#039;administrator&#039;);&lt;br /&gt;
	&lt;br /&gt;
		// Load the filter state.&lt;br /&gt;
		$search = $this-&amp;gt;getUserStateFromRequest($this-&amp;gt;context.&#039;.filter.search&#039;, &#039;filter_search&#039;);&lt;br /&gt;
		//Omit double (white-)spaces and set state&lt;br /&gt;
		$this-&amp;gt;setState(&#039;filter.search&#039;, preg_replace(&#039;/\s+/&#039;,&#039; &#039;, $search));&lt;br /&gt;
		&lt;br /&gt;
		//Filter (dropdown) state&lt;br /&gt;
		$state = $this-&amp;gt;getUserStateFromRequest($this-&amp;gt;context.&#039;.filter.state&#039;, &#039;filter_state&#039;, &#039;&#039;, &#039;string&#039;);&lt;br /&gt;
		$this-&amp;gt;setState(&#039;filter.state&#039;, $state);&lt;br /&gt;
&lt;br /&gt;
		//Filter (dropdown) company&lt;br /&gt;
		$state = $this-&amp;gt;getUserStateFromRequest($this-&amp;gt;context.&#039;.filter.company&#039;, &#039;filter_company&#039;, &#039;&#039;, &#039;string&#039;);&lt;br /&gt;
		$this-&amp;gt;setState(&#039;filter.company&#039;, $state);&lt;br /&gt;
	&lt;br /&gt;
		//Takes care of states: list. limit / start / ordering / direction&lt;br /&gt;
		parent::populateState(&#039;a.name&#039;, &#039;asc&#039;);&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FOR THE FRONTEND:&#039;&#039;&#039; your &#039;&#039;&#039;$app&#039;&#039;&#039; variable looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  protected function populateState($ordering = null, $direction = null)&lt;br /&gt;
        {&lt;br /&gt;
                // Initialise variables.&lt;br /&gt;
                $app = JFactory::getApplication();&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Modify View (views / zzz / view.html.php) ==&lt;br /&gt;
In you view class, you have to set the state, like this:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;gt;&lt;br /&gt;
		$this-&amp;gt;items		= $this-&amp;gt;get(&#039;Items&#039;);&lt;br /&gt;
		$this-&amp;gt;pagination	= $this-&amp;gt;get(&#039;Pagination&#039;);&lt;br /&gt;
		$this-&amp;gt;state		= $this-&amp;gt;get(&#039;State&#039;);&lt;br /&gt;
&lt;br /&gt;
		//Following variables used more than once&lt;br /&gt;
		$this-&amp;gt;sortColumn 	= $this-&amp;gt;state-&amp;gt;get(&#039;list.ordering&#039;);&lt;br /&gt;
		$this-&amp;gt;sortDirection	= $this-&amp;gt;state-&amp;gt;get(&#039;list.direction&#039;);&lt;br /&gt;
		$this-&amp;gt;searchterms	= $this-&amp;gt;state-&amp;gt;get(&#039;filter.search&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Modify Template (views / zzz / tmpl / default.php) ==&lt;br /&gt;
=== Basic ===&lt;br /&gt;
Top of template somewhere:&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
//Get companie options&lt;br /&gt;
JFormHelper::addFieldPath(JPATH_COMPONENT . &#039;/models/fields&#039;);&lt;br /&gt;
$companies = JFormHelper::loadFieldType(&#039;MyCompany&#039;, false);&lt;br /&gt;
$companyOptions=$companies-&amp;gt;getOptions(); // works only if you set your field getOptions on public!!&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
In your template file, this fieldset reflects filter options:&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;fieldset id=&amp;quot;filter-bar&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;div class=&amp;quot;filter-search fltlft&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;filter_search&amp;quot; id=&amp;quot;filter_search&amp;quot; value=&amp;quot;&amp;lt;?php echo $this-&amp;gt;escape($this-&amp;gt;searchterms); ?&amp;gt;&amp;quot; title=&amp;quot;&amp;lt;?php echo JText::_(&#039;Search in company, etc.&#039;); ?&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;button type=&amp;quot;submit&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;?php echo JText::_(&#039;JSEARCH_FILTER_SUBMIT&#039;); ?&amp;gt;&lt;br /&gt;
			&amp;lt;/button&amp;gt;&lt;br /&gt;
			&amp;lt;button type=&amp;quot;button&amp;quot; onclick=&amp;quot;document.id(&#039;filter_search&#039;).value=&#039;&#039;;this.form.submit();&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;?php echo JText::_(&#039;JSEARCH_FILTER_CLEAR&#039;); ?&amp;gt;&lt;br /&gt;
			&amp;lt;/button&amp;gt;&lt;br /&gt;
		&amp;lt;/div&amp;gt;&lt;br /&gt;
		&amp;lt;div class=&amp;quot;filter-select fltrt&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;select name=&amp;quot;filter_state&amp;quot; class=&amp;quot;inputbox&amp;quot; onchange=&amp;quot;this.form.submit()&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;option value=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
					&amp;lt;?php echo JText::_(&#039;JOPTION_SELECT_PUBLISHED&#039;);?&amp;gt;&lt;br /&gt;
				&amp;lt;/option&amp;gt;&lt;br /&gt;
				&amp;lt;?php echo JHtml::_(&#039;select.options&#039;, JHtml::_(&#039;jgrid.publishedOptions&#039;, array(&#039;archived&#039;=&amp;gt;false)), &#039;value&#039;, &#039;text&#039;, $this-&amp;gt;state-&amp;gt;get(&#039;filter.state&#039;), true);?&amp;gt;&lt;br /&gt;
			&amp;lt;/select&amp;gt;&lt;br /&gt;
			&lt;br /&gt;
			&amp;lt;select name=&amp;quot;filter_type&amp;quot; class=&amp;quot;inputbox&amp;quot; onchange=&amp;quot;this.form.submit()&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;option value=&amp;quot;&amp;quot;&amp;gt; - Select Company - &amp;lt;/option&amp;gt;&lt;br /&gt;
				&amp;lt;?php echo JHtml::_(&#039;select.options&#039;, $companyOptions, &#039;value&#039;, &#039;text&#039;, $this-&amp;gt;state-&amp;gt;get(&#039;filter.company&#039;));?&amp;gt;&lt;br /&gt;
			&amp;lt;/select&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;/div&amp;gt;&lt;br /&gt;
	&amp;lt;/fieldset&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Extra: highlighting search terms ===&lt;br /&gt;
Here is some extra to visually mark the found search terms in the results page.&amp;lt;br/&amp;gt;&lt;br /&gt;
==== Template ====&lt;br /&gt;
&amp;lt;u&amp;gt;Add this somewhere at top somehwere:&amp;lt;/u&amp;gt; &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$searchterms = $this-&amp;gt;state-&amp;gt;get(&#039;filter.search&#039;);&lt;br /&gt;
&lt;br /&gt;
//Highlight search terms with js (if we did a search =&amp;gt; more performant and otherwise crash)&lt;br /&gt;
if (strlen($searchterms)&amp;gt;1) JHtml::_(&#039;behavior.highlighter&#039;, explode(&#039; &#039;,$searchterms));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And further in your template, enclose the specific fields with the default highlighter finder.&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;u&amp;gt;Example:&amp;lt;/u&amp;gt;&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;highlighter-start&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
	&amp;lt;table class=&amp;quot;adminlist&amp;quot;&amp;gt;&lt;br /&gt;
	...&lt;br /&gt;
	&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;highlighter-end&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
==== CSS ====&lt;br /&gt;
If your default admin template doesn&#039;t have required css, you should add the class in your component css.&lt;br /&gt;
&amp;lt;u&amp;gt;Example in controller:&amp;lt;/u&amp;gt;&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JHtml::stylesheet(&#039;com_peopleactions/admin.css&#039;, array(), true);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;u&amp;gt;In admin.css:&amp;lt;/u&amp;gt;&amp;lt;source lang=&amp;quot;css&amp;quot;&amp;gt;&lt;br /&gt;
.highlight {   background: none repeat scroll 0 0 #FFFF00; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
[[User:riledhel|Javier Constanzo]]&lt;br /&gt;
&lt;br /&gt;
[[User:Doub1ejack|Doub1ejack]]&lt;br /&gt;
&lt;br /&gt;
[[User:E-builds|E-builds]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Component Development]]&lt;br /&gt;
[[Category:Tutorials]]&lt;br /&gt;
[[Category:Joomla! 1.6]]&lt;br /&gt;
[[Category:Joomla! 1.7]]&lt;br /&gt;
[[Category:Joomla! 2.5]]&lt;/div&gt;</summary>
		<author><name>Catanet</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Archived:How_to_add_custom_filters_to_components&amp;diff=84867</id>
		<title>Archived:How to add custom filters to components</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Archived:How_to_add_custom_filters_to_components&amp;diff=84867"/>
		<updated>2013-04-21T00:04:00Z</updated>

		<summary type="html">&lt;p&gt;Catanet: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{version/tutor|1.7,2.5}}{{RightTOC}}&lt;br /&gt;
== Overview ==&lt;br /&gt;
This is a how-to on how to add &#039;&#039;&#039;ordering&#039;&#039;&#039; and &#039;&#039;&#039;filtering&#039;&#039;&#039; (search, custom dropdown, state) to a component backend page.&amp;lt;br/&amp;gt;&lt;br /&gt;
This approach is almost exactly the same for the frontend.&amp;lt;br/&amp;gt;&lt;br /&gt;
{{notice|Is confirmed: it works also for the frontend. Article&#039;s title need to be changed and redirected.}} &lt;br /&gt;
&lt;br /&gt;
In general, the process of adding a &#039;&#039;&#039;custom field filter&#039;&#039;&#039; breaks down into the following steps:&lt;br /&gt;
* Creating the class that will generate the form dropdown options&lt;br /&gt;
* Adapting the view to display the form dropdown input&lt;br /&gt;
* Adapting the model to retrieve data from DB &amp;amp; to set submission values in the Joomla &#039;state&#039;. For a better understanding of the code samples, the db table is called &#039;my_company&#039; and the fields are: id, name, state, company, somefield, someotherfieldtosearchin.&lt;br /&gt;
&lt;br /&gt;
== Extend JFormFieldList (models / fields / fieldname.php) ==&lt;br /&gt;
Frequently your filter fields will be very basic; probably simply a dropdown list of one of the columns being displayed on the current page.  Regardless, you will need to create your own field element.  This really isn&#039;t a big deal - this file will probably be less than 70 lines, including comments.  The code below will generate the dropdown element to filter by companies.  For more information and complex examples on creating this class see [[Creating_a_custom_form_field_type]].&lt;br /&gt;
&lt;br /&gt;
My &#039;companies&#039; dropdown element:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
defined(&#039;JPATH_BASE&#039;) or die;&lt;br /&gt;
&lt;br /&gt;
jimport(&#039;joomla.html.html&#039;);&lt;br /&gt;
jimport(&#039;joomla.form.formfield&#039;);&lt;br /&gt;
jimport(&#039;joomla.form.helper&#039;);&lt;br /&gt;
JFormHelper::loadFieldClass(&#039;list&#039;);&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Custom Field class for the Joomla Framework.&lt;br /&gt;
 *&lt;br /&gt;
 * @package		Joomla.Administrator&lt;br /&gt;
 * @subpackage	        com_my&lt;br /&gt;
 * @since		1.6&lt;br /&gt;
 */&lt;br /&gt;
class JFormFieldMyCompany extends JFormFieldList&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * The form field type.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @var		string&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	protected $type = &#039;MyCompany&#039;;&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to get the field options.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @return	array	The field option objects.&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	public function getOptions()&lt;br /&gt;
	{&lt;br /&gt;
		// Initialize variables.&lt;br /&gt;
		$options = array();&lt;br /&gt;
&lt;br /&gt;
		$db	= JFactory::getDbo();&lt;br /&gt;
		$query	= $db-&amp;gt;getQuery(true);&lt;br /&gt;
&lt;br /&gt;
		$query-&amp;gt;select(&#039;id As value, name As text&#039;);&lt;br /&gt;
		$query-&amp;gt;from(&#039;#__my_companies AS a&#039;);&lt;br /&gt;
		$query-&amp;gt;order(&#039;a.name&#039;);&lt;br /&gt;
		$query-&amp;gt;where(&#039;state = 1&#039;);&lt;br /&gt;
&lt;br /&gt;
		// Get the options.&lt;br /&gt;
		$db-&amp;gt;setQuery($query);&lt;br /&gt;
&lt;br /&gt;
		$options = $db-&amp;gt;loadObjectList();&lt;br /&gt;
&lt;br /&gt;
		// Check for a database error.&lt;br /&gt;
		if ($db-&amp;gt;getErrorNum()) {&lt;br /&gt;
			JError::raiseWarning(500, $db-&amp;gt;getErrorMsg());&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		return $options;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Obviously, there is only one section here that needs to be customized: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
		$query-&amp;gt;select(&#039;id As value, name As text&#039;);&lt;br /&gt;
		$query-&amp;gt;from(&#039;#__my_companies AS a&#039;);&lt;br /&gt;
		$query-&amp;gt;order(&#039;a.name&#039;);&lt;br /&gt;
		$query-&amp;gt;where(&#039;state = 1&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the database name and adjust the sql as necessary.  This will produce the text and values for the select element options.  I highly recommend not changing the value and text names.  Although I did not test this theory, it seems likely that ancestor classes are expecting these names as keys in the resulting array.&lt;br /&gt;
&lt;br /&gt;
== Modify Model (models / zzz.php) ==&lt;br /&gt;
In your model you have to include these two functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
//Add this handy array with database fields to search in&lt;br /&gt;
	protected $searchInFields = array(&#039;text&#039;,&#039;a.name&#039;,&#039;someotherfieldtosearchin&#039;);&lt;br /&gt;
&lt;br /&gt;
//Override construct to allow filtering and ordering on our fields&lt;br /&gt;
	public function __construct($config = array()) {&lt;br /&gt;
	 	$config[&#039;filter_fields&#039;]=array_merge($this-&amp;gt;searchInFields,array(&#039;a.company&#039;));&lt;br /&gt;
		parent::__construct($config);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	protected function getListQuery(){&lt;br /&gt;
		$db = JFactory::getDBO();&lt;br /&gt;
		$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
&lt;br /&gt;
                //CHANGE THIS QUERY AS YOU NEED...&lt;br /&gt;
                $query-&amp;gt;select(&#039;id As value, name As text, somefield&#039;)&lt;br /&gt;
			-&amp;gt;from(&#039;#__my_companies AS a&#039;)&lt;br /&gt;
			-&amp;gt;order(	$db-&amp;gt;escape($this-&amp;gt;getState(&#039;list.ordering&#039;, &#039;pa.id&#039;)) . &#039; &#039; .&lt;br /&gt;
					$db-&amp;gt;escape($this-&amp;gt;getState(&#039;list.direction&#039;, &#039;desc&#039;)));&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
		&lt;br /&gt;
		// Filter search // Extra: Search more than one fields and for multiple words&lt;br /&gt;
		$regex = str_replace(&#039; &#039;, &#039;|&#039;, $this-&amp;gt;getState(&#039;filter.search&#039;));&lt;br /&gt;
		if (!empty($regex)) {&lt;br /&gt;
			$regex=&#039; REGEXP &#039;.$db-&amp;gt;quote($regex);&lt;br /&gt;
			$query-&amp;gt;where(&#039;(&#039;.implode($regex.&#039; OR &#039;,$this-&amp;gt;searchInFields).$regex.&#039;)&#039;);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		// Filter company&lt;br /&gt;
		$company= $db-&amp;gt;escape($this-&amp;gt;getState(&#039;filter.company&#039;));&lt;br /&gt;
		if (!empty($company)) {&lt;br /&gt;
			$query-&amp;gt;where(&#039;(a.company=&#039;.$company.&#039;)&#039;);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		// Filter by state (published, trashed, etc.)&lt;br /&gt;
		$state = $db-&amp;gt;escape($this-&amp;gt;getState(&#039;filter.state&#039;));&lt;br /&gt;
		if (is_numeric($state)) {&lt;br /&gt;
			$query-&amp;gt;where(&#039;a.state = &#039; . (int) $state);&lt;br /&gt;
		}&lt;br /&gt;
		elseif ($state === &#039;&#039;) {&lt;br /&gt;
			$query-&amp;gt;where(&#039;(a.state = 0 OR a.state = 1)&#039;);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		//echo $db-&amp;gt;replacePrefix( (string) $query );//debug&lt;br /&gt;
		return $query;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method to auto-populate the model state.&lt;br /&gt;
	 *&lt;br /&gt;
	 * Note. Calling getState in this method will result in recursion.&lt;br /&gt;
	 *&lt;br /&gt;
	 * @since	1.6&lt;br /&gt;
	 */&lt;br /&gt;
	protected function populateState($ordering = null, $direction = null)&lt;br /&gt;
	{&lt;br /&gt;
		// Initialise variables.&lt;br /&gt;
		$app = JFactory::getApplication(&#039;administrator&#039;);&lt;br /&gt;
	&lt;br /&gt;
		// Load the filter state.&lt;br /&gt;
		$search = $this-&amp;gt;getUserStateFromRequest($this-&amp;gt;context.&#039;.filter.search&#039;, &#039;filter_search&#039;);&lt;br /&gt;
		//Omit double (white-)spaces and set state&lt;br /&gt;
		$this-&amp;gt;setState(&#039;filter.search&#039;, preg_replace(&#039;/\s+/&#039;,&#039; &#039;, $search));&lt;br /&gt;
		&lt;br /&gt;
		//Filter (dropdown) state&lt;br /&gt;
		$state = $this-&amp;gt;getUserStateFromRequest($this-&amp;gt;context.&#039;.filter.state&#039;, &#039;filter_state&#039;, &#039;&#039;, &#039;string&#039;);&lt;br /&gt;
		$this-&amp;gt;setState(&#039;filter.state&#039;, $state);&lt;br /&gt;
&lt;br /&gt;
		//Filter (dropdown) company&lt;br /&gt;
		$state = $this-&amp;gt;getUserStateFromRequest($this-&amp;gt;context.&#039;.filter.company&#039;, &#039;filter_company&#039;, &#039;&#039;, &#039;string&#039;);&lt;br /&gt;
		$this-&amp;gt;setState(&#039;filter.company&#039;, $state);&lt;br /&gt;
	&lt;br /&gt;
		//Takes care of states: list. limit / start / ordering / direction&lt;br /&gt;
		parent::populateState(&#039;a.name&#039;, &#039;asc&#039;);&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Modify View (views / zzz / view.html.php) ==&lt;br /&gt;
In you view class, you have to set the state, like this:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;gt;&lt;br /&gt;
		$this-&amp;gt;items		= $this-&amp;gt;get(&#039;Items&#039;);&lt;br /&gt;
		$this-&amp;gt;pagination	= $this-&amp;gt;get(&#039;Pagination&#039;);&lt;br /&gt;
		$this-&amp;gt;state		= $this-&amp;gt;get(&#039;State&#039;);&lt;br /&gt;
&lt;br /&gt;
		//Following variables used more than once&lt;br /&gt;
		$this-&amp;gt;sortColumn 	= $this-&amp;gt;state-&amp;gt;get(&#039;list.ordering&#039;);&lt;br /&gt;
		$this-&amp;gt;sortDirection	= $this-&amp;gt;state-&amp;gt;get(&#039;list.direction&#039;);&lt;br /&gt;
		$this-&amp;gt;searchterms	= $this-&amp;gt;state-&amp;gt;get(&#039;filter.search&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Modify Template (views / zzz / tmpl / default.php) ==&lt;br /&gt;
=== Basic ===&lt;br /&gt;
Top of template somewhere:&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
//Get companie options&lt;br /&gt;
JFormHelper::addFieldPath(JPATH_COMPONENT . &#039;/models/fields&#039;);&lt;br /&gt;
$companies = JFormHelper::loadFieldType(&#039;MyCompany&#039;, false);&lt;br /&gt;
$companyOptions=$companies-&amp;gt;getOptions(); // works only if you set your field getOptions on public!!&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
In your template file, this fieldset reflects filter options:&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;fieldset id=&amp;quot;filter-bar&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;div class=&amp;quot;filter-search fltlft&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;filter_search&amp;quot; id=&amp;quot;filter_search&amp;quot; value=&amp;quot;&amp;lt;?php echo $this-&amp;gt;escape($this-&amp;gt;searchterms); ?&amp;gt;&amp;quot; title=&amp;quot;&amp;lt;?php echo JText::_(&#039;Search in company, etc.&#039;); ?&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;button type=&amp;quot;submit&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;?php echo JText::_(&#039;JSEARCH_FILTER_SUBMIT&#039;); ?&amp;gt;&lt;br /&gt;
			&amp;lt;/button&amp;gt;&lt;br /&gt;
			&amp;lt;button type=&amp;quot;button&amp;quot; onclick=&amp;quot;document.id(&#039;filter_search&#039;).value=&#039;&#039;;this.form.submit();&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;?php echo JText::_(&#039;JSEARCH_FILTER_CLEAR&#039;); ?&amp;gt;&lt;br /&gt;
			&amp;lt;/button&amp;gt;&lt;br /&gt;
		&amp;lt;/div&amp;gt;&lt;br /&gt;
		&amp;lt;div class=&amp;quot;filter-select fltrt&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;select name=&amp;quot;filter_state&amp;quot; class=&amp;quot;inputbox&amp;quot; onchange=&amp;quot;this.form.submit()&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;option value=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
					&amp;lt;?php echo JText::_(&#039;JOPTION_SELECT_PUBLISHED&#039;);?&amp;gt;&lt;br /&gt;
				&amp;lt;/option&amp;gt;&lt;br /&gt;
				&amp;lt;?php echo JHtml::_(&#039;select.options&#039;, JHtml::_(&#039;jgrid.publishedOptions&#039;, array(&#039;archived&#039;=&amp;gt;false)), &#039;value&#039;, &#039;text&#039;, $this-&amp;gt;state-&amp;gt;get(&#039;filter.state&#039;), true);?&amp;gt;&lt;br /&gt;
			&amp;lt;/select&amp;gt;&lt;br /&gt;
			&lt;br /&gt;
			&amp;lt;select name=&amp;quot;filter_type&amp;quot; class=&amp;quot;inputbox&amp;quot; onchange=&amp;quot;this.form.submit()&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;option value=&amp;quot;&amp;quot;&amp;gt; - Select Company - &amp;lt;/option&amp;gt;&lt;br /&gt;
				&amp;lt;?php echo JHtml::_(&#039;select.options&#039;, $companyOptions, &#039;value&#039;, &#039;text&#039;, $this-&amp;gt;state-&amp;gt;get(&#039;filter.company&#039;));?&amp;gt;&lt;br /&gt;
			&amp;lt;/select&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;/div&amp;gt;&lt;br /&gt;
	&amp;lt;/fieldset&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Extra: highlighting search terms ===&lt;br /&gt;
Here is some extra to visually mark the found search terms in the results page.&amp;lt;br/&amp;gt;&lt;br /&gt;
==== Template ====&lt;br /&gt;
&amp;lt;u&amp;gt;Add this somewhere at top somehwere:&amp;lt;/u&amp;gt; &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$searchterms = $this-&amp;gt;state-&amp;gt;get(&#039;filter.search&#039;);&lt;br /&gt;
&lt;br /&gt;
//Highlight search terms with js (if we did a search =&amp;gt; more performant and otherwise crash)&lt;br /&gt;
if (strlen($searchterms)&amp;gt;1) JHtml::_(&#039;behavior.highlighter&#039;, explode(&#039; &#039;,$searchterms));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And further in your template, enclose the specific fields with the default highlighter finder.&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;u&amp;gt;Example:&amp;lt;/u&amp;gt;&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;highlighter-start&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
	&amp;lt;table class=&amp;quot;adminlist&amp;quot;&amp;gt;&lt;br /&gt;
	...&lt;br /&gt;
	&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;highlighter-end&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
==== CSS ====&lt;br /&gt;
If your default admin template doesn&#039;t have required css, you should add the class in your component css.&lt;br /&gt;
&amp;lt;u&amp;gt;Example in controller:&amp;lt;/u&amp;gt;&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JHtml::stylesheet(&#039;com_peopleactions/admin.css&#039;, array(), true);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;u&amp;gt;In admin.css:&amp;lt;/u&amp;gt;&amp;lt;source lang=&amp;quot;css&amp;quot;&amp;gt;&lt;br /&gt;
.highlight {   background: none repeat scroll 0 0 #FFFF00; }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Contributors ==&lt;br /&gt;
[[User:riledhel|Javier Constanzo]]&lt;br /&gt;
&lt;br /&gt;
[[User:Doub1ejack|Doub1ejack]]&lt;br /&gt;
&lt;br /&gt;
[[User:E-builds|E-builds]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Component Development]]&lt;br /&gt;
[[Category:Tutorials]]&lt;br /&gt;
[[Category:Joomla! 1.6]]&lt;br /&gt;
[[Category:Joomla! 1.7]]&lt;br /&gt;
[[Category:Joomla! 2.5]]&lt;/div&gt;</summary>
		<author><name>Catanet</name></author>
	</entry>
</feed>