0

I built a view (call it 'history') to display a list of historic records with couple filters. A change of filter value will trigger the submit (onchange = "submit();"). The view will get the new filter values from _POST variables and update the list.

I have this history view on both frontend and backend with the same code. The backend works fine. I can filter the records and then click the page links (1, 2, 3 etc.) to roll the page. The records will stay filtered. But in the front end, whenever I click the page link, the filter values are lost and the list goes back to default filter values.

Inspection shows that clicking the page links in the backend will send a POST request with the filter values in $POST. But when clicking the page links in the front end, no POST request is sent. I have method="post" in the form and the pagination->getListFooter() is in the that form. Is there anything extra needed for the frontend.

In tmpl/default.php:

...

JHTML::_('formbehavior.chosen', 'select');

...

<form action="<?php echo Route::_('index.php?option=com_mycomponent&view=history'); ?>" method="post" name="adminForm" id="adminForm">

 ...

    <td>
         <?php echo $this->lists['record_type']; ?>
    </td>
     <td>
          <?php echo $this->lists['record_id']; ?>
     </td>

...

     <td colspan="5">
          <?php echo $this->pagination->getListFooter(); ?>
     </td>

....

    <input type="hidden" name="task" value=""/>
</form>

In view.html.php:

...

$this->pagination   = $this->get('Pagination');

In history.php (model), I did not override pagination method:

class MyComponentModelHistory extends ListModel
{ 
    ... 
}
  • This is expected. Whether or not a form is submitted depends on Pagination overrides in the template. Protostar, Joomla's default site template, does not submit the form when a pagination link is clicked. – Sharky Apr 24 at 6:41
  • Assuming you want this to work like Joomla's core components, you need to store filters in the session. This would be done in the model. – Sharky Apr 24 at 6:43
  • Thanks for the comments. I searched online and found Joomla frontend pagination does not send POST request. I worked around this issue by storing those filter values in userstate as recommended in the comment. – waze Apr 24 at 20:28

Your Answer

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

Browse other questions tagged or ask your own question.