I have followed the article on the Joomla Developer Sites to create a sorting filter for my list (https://docs.joomla.org/Adding_sortable_columns_to_a_table_in_a_component).

But I cannot get it work. Step 2 explains how to get the State of the sorting. But the state is NULL after calling get GetState-Method. Here is the Method I have used.
$state = $this->get('State');

Best regards tria1312

1 Answer 1


The meaning of $state = $this->get('State'); is $state = $model->getState(); where $model is the current model of your view.

If your model is extending from JModelList, all your state variables are automatically populated (provided correct values present in request). Otherwise populate the state in your model's populateState function.

protected function populateState ($ordering = 'sort_order', $direction = 'ASC')
  $orderCol = $app->input->get('filter_order', $ordering);
  $this->setState('list.ordering', $orderCol);

Note: Never call getState function in populateState, which creates infinite loop.

  • Does it also work with the JModelLegacy Class?
    – tria1312
    Commented Aug 22, 2016 at 19:43
  • Yes. you can add your own populateState method in your model and populate the values from request manually.
    – Nagarjun
    Commented Aug 22, 2016 at 20:10
  • OK, thats working. And now I want to have the state populated when a request with special task is called. How does this work? In that case my list.ordering is always empty.
    – tria1312
    Commented Aug 22, 2016 at 21:27
  • I found it. You have to fetch the State by calling the Method $app->getUserState( 'list.column', 'default_column_name' );
    – tria1312
    Commented Aug 22, 2016 at 22:02

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.