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.

3 Answers 3

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);
}
1
  • Joomla never stops failing me
    – ashutosh
    Sep 27, 2017 at 18:22
5

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

1
  • thanks for the suggestion to add it after parent method call
    – Ignis
    Mar 2, 2016 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 and acknowledge you have read our privacy policy.

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