antpre Posted February 19, 2016 Share Posted February 19, 2016 Hello everyone, Is it possible to use 2 pagers to paginate 2 differents lists of pages (for example 1 news list and 1 blog post list) on one single template. I have tried it and it seems that the two pagers interfer with each other. For example if both the pagers are on n°1. if I click on the link to go to pagination 3 of the news list pager. When the page reloads then the the pager of the news list is on pagination 3 - thats ok- but the pager of blog post list has also shifted to pagination 3 -that's not ok- and vice versa (if I user the pager of the other list it afects the display of the first list).Is it a normal behavior ... Or maybe I am juste doing it wrong Thanks in advance Link to comment Share on other sites More sharing options...
LostKobrakai Posted February 19, 2016 Share Posted February 19, 2016 You can render two independent paginations, but only use one at a time. You'd use the getVars option or $input->whitelist() (if you need some filter values to be populated as well) to add a kinda "switch" GET variable, which tells you which pagination is currently used. When you know which pagination was clicked you can manually set the "start=" part to only the selector of the clicked pagination. There's no automated way to differenciate multiple paginations. 1 Link to comment Share on other sites More sharing options...
antpre Posted February 19, 2016 Author Share Posted February 19, 2016 Thanks a lot. I will try this and let you know if managed it ! Link to comment Share on other sites More sharing options...
antpre Posted February 19, 2016 Author Share Posted February 19, 2016 OK done. It's working. As you mentionned, I passed a variable to know which pager was clicked and I added a condition before each of the selectors so that when the pager of the other selector was clicked that pager sticks to the first pagination. Thanks a lot Link to comment Share on other sites More sharing options...
LostKobrakai Posted February 19, 2016 Share Posted February 19, 2016 I just copied the parts I used to one piece. You could also use different GET variables, but keep in mind to unset these again after rendering a single pagination. public function pageStart($limit){ $limit = (int) $limit; if(wire('input')->pageNum === 1 || $limit < 1){ return 0; } return (wire('input')->pageNum - 1) * $limit; } $pa = $pages->find("…, limit=15, start=".(!$input->get->second ? pageStart(15) : 0); $pa2 = $pages->find("…, limit=15, start=".($input->get->second ? pageStart(15) : 0); $pagination = $pa->renderPager(); $input->whitelist("second", 1); $pagination2 = $pa2->renderPager(); 1 Link to comment Share on other sites More sharing options...
antpre Posted February 19, 2016 Author Share Posted February 19, 2016 Great. Now I understand how to do it. I'll try to implement it tomorrow.Very kind of you. Thanks again Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now