entschleunigung Posted April 7, 2021 Share Posted April 7, 2021 Hello all, paginating 'normal' pages and subpages is not a problem, but i have a merged array here that is not working. at the end i would like to have a page that has several areas with pagination. you know this from the admin area, there's an ajax pagination if you have many pages in a tree. something like this: DE 1. News title 2. News title ... 10. News title Pagination for DE 1 - 2 - 3 - 4 ... EN 1. News title 2. News title ... 10. News title Pagination for EN 1 - 2 - 3 - 4 ... ES 1. News title 2. News title ... 10. News title Pagination for ES 1 - 2 - 3 - 4 ... this is the way to build the array: $mailings_natural_sort = $page->children()->each(function ($natural) { $natural->custom_sort = $natural->created; }); $mailings_custom_sort = $page->children("news_alt_date!=''")->each(function ($custom) { $custom->custom_sort = $custom->news_alt_date; }); $all_mailings = $mailings_natural_sort->add($mailings_custom_sort)->sort('custom_sort'); the mailings are still split into languages assigned to backend, that's done here foreach ($languages as $language) { $news_related = $all_mailings->find("refNewsLanguages=$language, listMailing=0, start=0, limit=10"); if (count($news_related)) { foreach ($news_related as $mailing) { // list news } // for testing // echo $news_related; // returns 10400|10668|10610|10217|10580|10653|10598|10631|10566|10625 // why this not work? $pagination = $news_related->renderPages(); echo $pagination; // returns nothing, nada, zero } } the prerequisite for pagination is given, "Allow Page Numbers" enabled on the list page. why this not work? and has anyone ever implemented pagination with ajax and has an example of it? for relevant hints will ich auch einen Kasten Spezi springen lassen ? Link to comment Share on other sites More sharing options...
BitPoet Posted April 7, 2021 Share Posted April 7, 2021 2 hours ago, entschleunigung said: why this not work? Try renderPager() instead of renderPages(). And remove start=0, this prevents MarkupPageNav from increasing the offset. Only use it when you explicitly don't want to paginate your results. 2 hours ago, entschleunigung said: has anyone ever implemented pagination with ajax A number of times. I've put together a small example that works with the skyscraper demo since my original content is too specific. You can download the profile for that site here on GitHub and copy it into a (uninstalled) PW installation, then install PW with the skyscraper site profile (make sure to read up on the FieldtypeMapMarker issue in the README on GitHub). After installation, drop the template file from the attached zip into the templates folder, log into the backend and create a new template "paginated" for the file. In the template's URLs settings, enable page numbers and url segments. Then create a new page under home with the new template, give it a title and publish it. Voila, you should be ready to go. When you visit your new page, it should look like this: The pagination links should load the content through ajax. paginated.zip 1 1 Link to comment Share on other sites More sharing options...
entschleunigung Posted April 7, 2021 Author Share Posted April 7, 2021 thank you very much, this looks promising. I imagined it to be exactly like your screenshot. i will test it as soon as i am back in the office. 11 minutes ago, BitPoet said: Try renderPager() instead of renderPages(). And remove start=0, this prevents MarkupPageNav from increasing the offset. Only use it when you explicitly don't want to paginate your results. unfortunately, that didn't work, so that wasn't the problem. var_dump still says NULL. (I was quite ready to laugh at myself). cheers Link to comment Share on other sites More sharing options...
entschleunigung Posted April 19, 2021 Author Share Posted April 19, 2021 Hi BitPoet, it is not forgotten. thank you again for your support, it all worked out in the end. your attached file was a great help to me. 1 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