I have a fairly straightforward front end List display with pagination and headings that can sort columns and navigate to a different page number and everything works as expected. The URL for the page is mysite/stock-request and for any of the pagination or heading links the URL target is mysite/stock-request# created by this JS being used under a heading link,

onclick="Joomla.tableOrdering('a.Description','asc','');return false;" 

I mention the JS as I did find a thread somewhere mentioning that if JS was involved things happen a bit differently but now that I am looking for it I can find it.

My menu item link to get to the View is specified as this


I have added a couple of extra Input fields to each line on the list to allow the end-user to adjust a stock quantity inline and when I have these lines in the bottom of the <form>and it is the addition of task field and in particular coming back from the 'process' method that the problems begins.

<input type="hidden" name="task" value="stockrequests.process"/>
<input type="hidden" name="view" value=""/> 
<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>"/>
<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>"/>

Each time the user navigates to a different page or changes the sort order the <form> is submited and the subcontroller 'stockrequests' is called and task 'process' is run, all still working as expected. I am extending JControllerForm in 'stockrequests' and a check of the variable $_POST for limit and limistart show the updated values are there and getUserState shows the values for the selected ordering is available.

 [filter_order] => a.OrderQty [filter_order_Dir] => asc

Now my problem begins, I think, with the way I am trying to go back to the View. I have tried various techniques I have found with no success but these are the two I keep coming back to.

//$this->setRedirect('index.php?option=com_inventory&view=stockrequests?&limitstart=' . $_POST['limitstart']);

When I get back the View the URL is no longer myste/stock-request but mysite/index.php?option=com_inventory&view=stockrequests and the limit setting values are what they were before the end-user caused the page to change if I don't supply them via the limistart parm that is commented out. While the ordering settings have gone back to the defaults specified in the model.

[list.limit] => 20
[list.start] => 0
[list.ordering] => a.ItemCode
[list.direction] => 

What I am hoping to achieve is to come back to the View with the values for list ordering or page navigation that were set when I left the View are used to display the next page or sort the list differently.

Initially I thought it was some issue with UserState or State but as I can see they are set correctly while still in the subController I am guessing it is some issue with the approach for getting back to the View that it is treating it as new View or is not correctly getting the updated values.

Keeping in mind that the limit and limitstart value are what they were before the task is called, not the new values in $_Post array when in the 'process' task, suggesting something is remembered or passed through. While the List ordering goes back to he default settings suggesting it is treating it as a new or different View display.

I have figured out some hack work arounds but I have spent more than a days worth of effort trying to make this work as I want to use the inline editing elsewhere in this extension so any suggestions or pointers in the right direction will be much appreciated.

Other related items might be this in the stockrequest model.

    public function populateState($ordering = null, $direction = null)
        $app  = Factory::getApplication();
        $list = $app->getUserState($this->context . '.list');
echo "<pre> Ordering settings ..."; print_r($ordering);"</pre>";
        $ordering  = isset($list['filter_order'])     ? $list['filter_order']     : null;
        $direction = isset($list['filter_order_Dir']) ? $list['filter_order_Dir'] : null;

        $list['limit']     = '0'; // (int) Factory::getConfig()->get('list_limit', 20);
        $list['start']     = $app->input->getInt('start', 0);
        $list['ordering']  = $ordering;
        $list['direction'] = $direction;
echo "<pre> List settings 2..."; print_r($list);"</pre>";

        $app->setUserState($this->context . '.list', $list);
        $app->input->set('list', null);

        // List state information.
        parent::populateState('a.ItemCode', 'asc');

        $context = $this->getUserStateFromRequest($this->context . '.context', 'context', 'com_inventory.stockrequests', 'CMD');
        $this->setState('filter.context', $context);
echo "<pre> Context settings ..."; print_r($this->context);"</pre>";

        // Split context into component and optional section
        $parts = FieldsHelper::extract($context);

        if ($parts)
            $this->setState('filter.component', $parts[0]);
            $this->setState('filter.section', $parts[1]);

And this from the top of my form

<!-- action="<?php // echo JRoute::_('index.php?option=com_inventory&task=stockrequests.process&view=stockrequests'); ?>" -->
<form   action="<?php  echo htmlspecialchars(JUri::getInstance()->toString()); ?>"

    <?php echo JLayoutHelper::render('default_filter', array('view' => $this), dirname(__FILE__)); ?>

2 Answers 2


It doesn't look like you are including the menu Itemid in your redirect which is why your URL is changing. Add another hidden field with the value of your current Itemid. Your redirect code is fine just add the &Itemid= portion to include the value that you are passing.

  • Thanks for replying. I tried to include the Menu Id and I am not sure I added it to the redirect correctly but I ended up back on the right View but with the URL still in the non-SEF form, mysite/index.php?option=com_inventory&view=stockrequests&ItemId=570
    – Irata
    Sep 23, 2019 at 10:17
  • Sorry I misread your code example. Try $this->setRedirect(JRoute::_('index.php?option=com_inventory&view=stockrequests&ItemId=570'))
    – Terry Carter
    Sep 24, 2019 at 17:14
  • You need to have the JRoute portion in there to build your return URL to be SEO friendly.
    – Terry Carter
    Sep 24, 2019 at 17:15
  • Yesterday I came across JRroute in something else I had written and noticed it was solving the SEF issue so I had used that but it was still not quite right. In my example I have used ItemId and not Itemid so I fixed that and got your suggestion to work as far the SEF and dropped the view. This is what I used, $this->setRedirect(JRoute::_('index.php?option=com_inventory&Itemid=' . $_POST['menu_id'])); And then being on a roll I found this actually works just how I wanted $this->setRedirect(JRoute::_('index.php?option=com_inventory')); No menu item required. Thanks for your help.
    – Irata
    Sep 24, 2019 at 22:53
  • Adding a menu Itemid is mostly important when you have an extension with separate views, each having its own menu item on the system. For instance if you had an automotive extension with a separate page for cars and trucks. Including the Itemid lets the system know which page to return to.
    – Terry Carter
    Sep 26, 2019 at 17:36

An approach I have found that works for my situation in regards to the returning to the same URL is the use of a hidden input to grab the URI as I want it and then plug it into the redirect in the controller to come back.

In the View default.php I have this,

<input type="hidden" name="return_url" value="<?php  echo htmlspecialchars(JUri::getInstance()->toString()); ?>">

and in my subController I have


This might help someone else who finds this thread.

I am still struggling with the holding of the State variable but I have progressed to see that com_content does achieve what I want to do so I now know it is possible, just have to work out exactly how.

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.