5

By default, populateState seems to limit a call to any model's get('Items') function to 20 items.

How can this be overridden - by re-writing populateState? By writing a separate function in the model? I've gone for the second option...

public function getAll(){
    return $this->_getList($this->getListQuery());
}

which works, but I think there's a more Joomla-ish way of doing this - I just can't find it.

5

To answer the question in the title about "setting" the limit, this is done in the Joomla global configuration: "Default List Limit".

To override, Joomla components generally seem to use this in the model: Using $limit = 0 shows all items

protected function populateState($ordering = null, $direction = null)
{
    // set limit
    $this->setState('list.limit', $limit);
    // set start (eg. what record to begin pagination at)
    $this->setState('list.start', $value);
}
  • Joomla never stops failing me – ashutosh Sep 27 '17 at 18:22
4

Like others have said - put this in the model's populateState function

$this->setState('list.limit', $limit); #limit=0 removes limit
$this->setState('list.start', $start);

But you must make sure that these lines are AFTER

parent::populateState($order, $dir);

or the parent class will override your values

  • thanks for the suggestion to add it after parent method call – shine Mar 2 '16 at 6:39
1

Try this also

protected function populateState($ordering = null, $direction = null)
    {
    // Load the list state.
    $this->setState('list.start', 0);
    $this->setState('list.limit', 10);
    }

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.