0

In my component, I am using Joomla default pagination calling $this->pagination->getPagesLinks() in the view template file.

Say, my component url is like this at a certain point: http://localhost/joomla/index.php/menu-item-name?cid=79&tid=3 and when a page link is clicked, I want that url to omit the component related parameters (cid=79&tid=3). So when going to the desired page, that url becomes http://localhost/joomla/index.php/menu-item-name?start=2.

So how do I achieve this? What pagination class functions can I override? I could not find a way because if I override getPagesLinks() in the JPagination class, it would not work because pagination links are generated from template's overridden files too.

Please help me in both Joomla 2.5 and 3

Edit: Ok, I implemented router.php. In it's build() function...

$segments[] = $query['cid'];
$segments[] = $query['tid'];
if (isset($query['start'])) {
    $segments[] = $query['start'];
    unset($query['start']);
}
unset($query['cid']);
unset($query['tid']);
unset($query['view']);

and in the parse() function...

$vars['view'] = 'category';
$vars['cid'] = $segments[0];
$vars['tid'] =  $segments[1];
$vars['start'] =  $segments[2];
return $vars;

So when I load my component without any variables in the url, the next page link in pagination becomes http://localhost/joomla3.3/menu-item-name/2, even when component has some variables in the url then the url look like http://localhost/joomla3.3/menu-item-name/4/79/2. Both of these urls' last 2 is the pagination's page value (like start=2), but when I click a page link, it's not going to next page but staying and loading some items in same page.

So how do I make the pagination links work with router because I don't simply want ?start=2 to be added to the end of the url.

  • Little correction- if there is cid variable in url then only it will be kept. – dev-m May 31 '14 at 0:50
1

It sounds like you don't have a router.php for your extension to create the SEF URLs. If you look at the JPagination class you'll see that it calls JRoute::_() when it builds the links for the pagination elements, e.g.

$data->start->base = '0';
$data->start->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=0');
$data->previous->base = $page;
$data->previous->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $page);

The Joomla Doc's website has an article that covers "Supporting SEF URLs in your component" for Joomla 2.5+. There's also an article on SEF URL's in general for Joomla.

There's also a new JRouter implementation in 3.3+ which is faster but I'm not sure if that affects implementation specifics.

Update: Here's some details on the changes that were merged into J3.3

  • I can do all but problem is with joomla default pagination links.Although i assign pagination's start value in segments in build() function in router.php and corresponding $vars['start'] in parse method, it seems pagination not getting start value from parse method.So there are various conflicts with pagination links.Isn't it possible to construct pagination link urls according to router file too? any suggestions? – dev-m May 31 '14 at 23:55
  • I think you may have a problem in your router.php file. JRoute uses your components router.php, JPagination uses JRoute to build the links so you shouldn't have to do anything else if you've got your router working. You do have the SEF options turned on and your .htaccess enabled right? – Craig Jun 1 '14 at 2:56
  • I edited question to include codes about my prob.please look at it. – dev-m Jun 1 '14 at 13:49
  • Please put the whole router.php file in the question so we can see it in context. – Craig Jun 1 '14 at 21:12
  • These are all functional codes of those two functions in router.php i already put. Some other couple of lines like $segments = array(); need not mention here as you can guess. – dev-m Jun 1 '14 at 21:22
0

There is the issue with joomla pagination - you need to keep track of both start and limitstart as far as I know, because pagination link is:

<a href="#" onclick="document.adminForm.limitstart.value=5; Joomla.submitform();return false;">2</a>

And hidden input is also

<input type="hidden" name="limitstart" value="0">

So I believe if you'll keep track of this - you'll be fine.


But what if you-ll avoid this problem at all? Joomla pagination works in <form> so if you'll add

<form method="POST">

it will respect it end send your listlimit value quietly.

Your Answer

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

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