I'm learning Joomla Extension development and overriding getListQuery() method of a model that extends JModelList.

Now the problem is that we can retrieve a list of data from database using following which is working fine:

$db = $this->getDbo();
$query = $db->getQuery(true);

But my ebook use following statement

$this->getState('list.select','a.id, a.title,' .'a.state, a.company'));

I understand the getState() method but why does the ebook author use getState() in select statement? What is the purpose of using this and where the 'list.select' property will be defined?

1 Answer 1


Using state in the select statement allows external extensions to use your method individually and to get different sets of data from it.

A good example is mod_articles_news module helper which sets the fields for selection from the Articles Model:

// Get an instance of the generic articles model
$model = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true));


$model->setState('list.select', 'a.fulltext, a.id, a.title, a.alias, a.introtext, a.state, a.catid, a.created, a.created_by, a.created_by_alias,' .
' a.modified, a.modified_by, a.publish_up, a.publish_down, a.images, a.urls, a.attribs, a.metadata, a.metakey, a.metadesc, a.access,' .
' a.hits, a.featured, a.language');


$items = $model->getItems();
  • oh thanks a lot now i get it, the getState() will try to find the value of list.select but it will find nothing when component is executing so this will return 'a.title, a.name' as default values. and in the time of modules we will set models 'list.select' state value as what we need and we will get our result...! thanks again Feb 28, 2015 at 7:45
  • Yes you are right. Feb 28, 2015 at 8:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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