Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 482 Vote(s) - 3.58 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Joomla pagination across different components

#1
Because pagination is using `getUserStateFromRequest` method to get the `limit` and `limitstart` variable, I'm having a problem where as I navigate from one component to another, I'm shown a no items found message.

To clarify, I have a products component that has 3 pages worth of products listed. Then I have a branches component with 2 pages worth of branch information. So if I navigate to the third page in the products list, and then go to the branches component, nothing is displayed.

Has anyone any idea how to stop this from happening? Any way to maybe clear the session data?
Reply

#2
What I ended up doing was this,
in line 624 in libraries/joomla/application/application.php file I added the following lines



$this->setUserState('option','default');

$curr_comp = JRequest::getCmd( 'option' );;


if($this->getUserState('option') != $curr_comp)
{
$this->setUserState($option . 'limitstart',0);
$this->setUserState('option',$curr_comp);

}
so the whole function reads this,

public function getUserStateFromRequest($key, $request, $default = null, $type = 'none')
{

$this->setUserState('option','default');

$curr_comp = JRequest::getCmd( 'option' );


if($this->getUserState('option') != $curr_comp)
{
$this->setUserState($option . 'limitstart',0);
$this->setUserState('option',$curr_comp);

}
$cur_state = $this->getUserState($key, $default);
$new_state = JRequest::getVar($request, null, 'default', $type);


// Save the new value only if it was set in this request.
if ($new_state !== null)
{
$this->setUserState($key, $new_state);
}
else
{
$new_state = $cur_state;
}

return $new_state;
}


This seems to be working fine at the moment. But please test before implementing on a live site
Reply

#3
To prevent editing the core files, but with the effect limited to your extension (so other extensions could load at the wrong page, but not yours), and if your model extends modellist, override the `getStart()` method:

public function getStart()
{
$store = $this->getStoreId('getstart');
$input = JFactory::getApplication()->input;
$start = $limitstart = $input->getInt('limitstart', 0);
$this->setState('list.start', $limitstart); // maybe redundant

$limit = $this->getState('list.limit');
$total = $this->getTotal();
if ($start > $total - $limit)
{
$start = max(0, (int) (ceil($total / $limit) - 1) * $limit);
}

// Add the total to the internal cache.
$this->cache[$store] = $start;
return $this->cache[$store];
}

If you want a solution that works system-wide and for all extensions, you should be able to override modellist with your implementation in a plugin. Start [here][1].


[1]:

[To see links please register here]

Reply

#4
This is an old question, but I just had the same issue as the OP, but in my case with Joomla 3.4.3.

After a lot of digging and testing, I discovered a solution for this that doesn't involve any plugin or core change:

If you put `limitstart=0` in the URL, the pagination will restart for that page, and this solves the problem between menus.

The way to implement this could be either with javascript, or by overriding the menu module, I chose the override:

1. I just need this in some menus, so I placed a CSS class into the
menu link (edit the menu, and in the "Link Type" tab, place the CSS
class in the "Link CSS Style" field), in my case it was `"
video-area"` (without the quotes).
2. Add override (add the module to the `html` folder of your template,
in my case it was the menu module, so it was a matter of adding the
mod_menu folder: `templatefolder/html/mod_menu`)
3. In the override of the component part of the module
(`default_component.php`), check to see if we have the CSS class, if
so, add the extra query to the URL (I edited `case 0`):

`case 0: $paginationLinks = ""; if(isset($class) && strpos($class, '
video-area') !== false){ $paginationLinks =
"?limitstart=0&limit=12"; } ?><a <?php echo $class; ?>href="<?php
echo $item->flink; ?><?php echo $paginationLinks;?>" <?php echo
$title; ?>><span><?php echo $linktype; ?></span></a><?php break;`

**That's it! it solved my problem, and even the pagination links have the extra query :)**

**BONUS**: notice that I have `&limit=12`, this changes the limit for the pagination into `12` per page, without any extra code!, (before, I had a lot of code to implement this, and by adding this to the menu it calculates the correct page number and totals, and filters the query, nice one Joomla!)
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through