Using JPagination together with Grid.Sort in Frontend
If you don't know, you cannot directly use JPagination together with JHTML::_('grid.sort') in your component at frontend. I found this problem when I develop component to be used in Intranet. I want to let administrators of the component perform their functions in frontend. As you know in backend if they are administartor then I cannot limit their access to only one specific component. However I can do this in frontend and only give theme a registered group member.
The problem occurs if users click on the table header to sort using GRID.SORT and then they click on pagination links e.g. START, PREV, NEXT .... The component will let them to the wrong page. For example, first they go to the page with this url
index.php?option=com_jtimesheet&task=timesheet.getlist&m=my&Itemid=76
Here, I use controller.task in the url and there are many links with different paramerter m=my, m=all, m=approval etc. When a user goes to this page with above url. and clicks pagination link. It works fine as it creates correct link in this case but when the user clicks on grid to sort the url will reduced to index.php?option=com_jtimesheet&Itemid=76. This is action attribute on the form I used. Ok, there is no problem with grid.sort as I provide hidden input field in the form (task and m in this case). But if user click on pagination link it will go to url
index.php?option=com_jtimesheet&Itemid=76.
Which is not desired result. The problem occurs only in frontend as JPagination creates link like this <a href="/component/jtimesheet/?Itemid=76"...> and you may have seen the problem it constructs wrong url. But at backend JPagination use onclick of anchore instead like thisย ย <a href="#" onclick="javascript:........">. And it works in backend as all forms we used (if you familiar with it) are name "adminForm". But we don't have to do so in frontend (as in fromtend we want to use ToolBar and Joomla's JavaScript). You can change this to test if it work by changing pagination.php in your current template folder/html. So whatย are the solution?
