1

when we extends JmodelList for handling list of data in our List_Model in construct function we define filter_fields in config array like

$config[filter_fields]=array('field1','a.field1','field2','a.field2');
parent::__construct($config);

i'm wondering about the structure of defining filter_fields array in config array

why we define every fields two time and how they will be used by joomla.?
2

The filter fields list is a configuration option for ordering purposes, it's a white list of field names that are permitted for usage in queries, so apparently you can use a.field1 for instance as query specific.

So in your view, you write something like this:

<?php echo JHtml::_('grid.sort', 'COM_MYCOMPONENT_NAME', 'name', $listDirn, $listOrder); ?>

As we can see, in the third argument in this method, we apply the column name we want to order by, and here we could specify a table like p.name if it is the name from a joined table called people.

Both field1 and a.field1 are added possibly so that someone else wants to use this model, or for specification, like this example:

<?php echo JHtml::_('grid.sort', 'COM_MYCOMPONENT_NAME', 'p.name', $listDirn, $listOrder); ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.