Search the Community

Showing results for tags 'pagination'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Found 54 results

  1. I'm in the process of finalising a pw 3.0.62 and uikit3 based site which using the Reglar-Master profile and I've noticed pagination is missing despite the Allow Page Numbers? setting being enabled under the blog template URLs tab. The default blog.php template is as below: <div id='content'> <?php echo ukHeading1(page()->title, 'divider'); $posts = page()->children('limit=10'); echo ukBlogPosts($posts); ?> </div> Reducing the limit as follows does not result in any pagination being displayed despite there being 10 news posts. ... $posts = page()->children('limit=6'); ... If I have understood correctly, it should not be necessary to add the MarkupPagerNav module to this profile as the capability should already be already built-in. If that is the case, then I can only think that some additional code is required. Any help would be greatly appreciated.
  2. I am currently designing a search page for my website. While I am able to get both pagination and fieldtype caching enabled separately, I am not able to implement them together. I followed the following 2 pages - https://processwire.com/api/modules/markup-pager-nav/ https://processwire-recipes.com/recipes/set-up-search-index-with-fieldtypecache/ Is there any way where I can combine these 2 methods for my website? Here is a snippet of my code $q = $sanitizer->text($input->get->q); $q = $sanitizer->selectorValue($q); // Search the cacged fields for our query text. // Limit the results to 50 pages. $selector = "search_cache~=$q, limit=50"; // If user has access to admin pages, lets exclude them from the search results. if($user->isLoggedin()) $selector .= ", has_parent!=2"; // Find pages that match the selector $matches = $pages->find($selector); //Get range of paginated results $start = $matches->getStart() + 1; $end = $matches->getStart() + count($matches); $total = $matches->getTotal(); $content = "<p><b>Showing search results ". $start . " - ". $end . " of ".$total."</b></p>"; // did we find any matches? if($matches->count) { $content .= '<ul>'; foreach($matches as $match){ $content .= '<li>'. $match->parent->title . ': <a href="' . $match->url . '">' . $match->title . '</a></li>'; } $content .= '</ul>'; $content .= $matches->renderPager(array( 'listMarkup' => "<ul class='pagination'>{out}</ul>", 'nextItemLabel' => "Next", 'previousItemLabel' => "Previous", )); } else { // we didn't find any $content = "<strong>Sorry, no results were found.</<strong>"; }
  3. Hi Everyone. I need help to paginate search results generated from a search form. my search result url: http://mysite.com/search/?products=tshirt&size=xl how do I keep the value when generating pagination using MarkupPagerNav? like on SKyscrapers example: http://processwire.com/skyscrapers/search/page2?city=albuquerque (tried to look at the source code but can't find where Ryan set the pagination options, maybe I missed it? can someone point it out to me ) at the moment my pagination link only showing the page number without the get value i.e: http://mysite.com/search/page2 however, it showing correct results if I type the url manually like: http://mysite.com/search/page2?products=tshirt&size=xl I'm assuming I need to set the getVars in the pagination options can you give me example how to use the "getVars"? I've set the cache to 0 in the template setting. my code: $pagination = $matches->renderPager(array( 'nextItemLabel' => "»", 'previousItemLabel' => "«", 'listMarkup' => "<ul class='MarkupPagerNav pagination'>{out}</ul>", )); thank you!
  4. I have $results = $pages->find('template=boat_vessel, sort=-boat_date_list, start=0, limit=3, '.$selector); $content .= $results->renderPager(array( 'nextItemLabel' => "Next", 'previousItemLabel' => "Prev", 'listMarkup' => "<ul class='MarkupPagerNav'>{out}</ul>", 'itemMarkup' => "<li class='{class}'>{out}</li>", 'linkMarkup' => "<a href='{url}'><span>{out}</span></a>", 'numPageLinks' => 999, )); But I go to /page2 and the same 1st page of results is displayed, and the pagination itself doesn't change, there's no previous link, the page 1 link is still classified as current.
  5. Sorting with different selectors, pagination works good When I logged in as Admin. But for visitors it does not work. I think it is cache problem. Any idea ? Thank You. https://cdeniz.com/kutuphane/kisiler/?sort=dogumtarihi
  6. I use pagination modul. I have a field which has born year info. But I put the years with sign "-" for BC (Before Christ). my selector sorts like as text. -384, -4, -412 .. it must be: -412, -384, -4 selector: $pages=$page->children("limit=60, sort=date_field"); I want to order my pages like as php natsort function. thank you.
  7. Hi, I just wanted to check whether or not the following topic is still valid with respect to PW 3.x: https://processwire.com/talk/topic/22-how-to-build-a-news-page/ I am trying to integrate a news section into a basic multisite PW website installation (voluntary project) intended for a community of two villages. Currently there are 4 subdomains (hca-site, hfi-site, hhg-site, hps-site) that link back to the main domain website (https://thehanneys.uk) by clicking on their home buttons. I had a look at the Blog (ProcessBlog & MarkupBlog) module but it is not really what I'm looking for - a simple News section. At the moment we're just concentrating on getting the functionality in place. The styling can come later. The first issue encountered is that there is no checkbox under the Advanced section for "Page Numbers" to turn them on for the news-index template. Secondly, I don't understand why the following text is being displayed above the navigation when I expected it to be displayed after the page title. Thirdly, are the story pages displayed on the index page simply by creating a new child under News (page based on news-index.php template)? Showing 0 of 0 Article(s) | Page 1 of 0 The current code for the news-index.php template is as follows: <?php namespace ProcessWire; // basic-page.php template file // See README.txt for more information // Primary content is the page's body copy $content = $page->body; // If the page has children, then render navigation to them under the body. // See the _func.php for the renderNav example function. if($page->hasChildren) { $content .= renderNav($page->children); } // if the rootParent (section) page has more than 1 child, then render // section navigation in the sidebar if($page->rootParent->hasChildren > 1) { $sidebar = renderNavTree($page->rootParent, 3) . $page->sidebar; } // start the news stories list echo "<ul>"; // get the stories for this page $stories = $page->children("limit=6, sort=-date"); // note if you set the stories to sort by date descending on the /news/ page // in the admin, then you can omit the "sort=-date" above. // cycle through each story and print it in a <li> foreach($stories as $story) { echo " <li><a href='{$story->url}'>{$story->title}</a> <p><strong>Date:</strong> {$story->date}</p> {$story->body} </li> "; } echo "</ul>"; // get values for our placemarker headline $start = $stories->getStart(); $end = $start + count($stories); $total = $stories->getTotal(); $num = $input->pageNum; $lastNum = ceil($total / $stories->getLimit()); // output the placemarker headline echo "<h5>Showing $start - $end of $total Article(s) | Page $num of $lastNum</h5>"; // output pagination links echo $stories->renderPager(); The current code for the news-story.php template is as follows: <?php namespace ProcessWire; // basic-page.php template file // See README.txt for more information // Primary content is the page's body copy echo "<div id='bodycopy'>"; $content = $page->body; echo "</div>"; // If the page has children, then render navigation to them under the body. // See the _func.php for the renderNav example function. if($page->hasChildren) { $content .= renderNav($page->children); } // if the rootParent (section) page has more than 1 child, then render // section navigation in the sidebar if($page->rootParent->hasChildren > 1) { $sidebar = renderNavTree($page->rootParent, 3) . $page->sidebar; } P.S. Are there any books/tutorials specifically covering PW 3.x? Any assistance would be greatly appreciated.
  8. Hi. I've got a client that wishes to see all the page links in the rendered pagination, without the separator (...). Is this possible? I know the page links may get reeeeally long, but that's what he wants. I know there are optional arguments that can be passed to renderPager(), but I can't see one for removing the separator. Any suggestions folks?
  9. Hi, I am using pagination with ajax. When i click on any page number url not changing because of ajax call So when i click on page 3 and then click on page 7 i hit the back button it returns to page 1 because url never changing Here is my site: www.sediremlak.com For real estate sites if visitor find a property on page 4 and click on that property page. After click on back button site jumps to first page or home page not page 4 How can i fix this problem?
  10. Hello PW community, I've a search form which return selected items with pagination. Everything works fine, also the pagination display correctly all results through pages. The issue is given only for selected results pagination as the latter does not start from page 1 but it revert back results from the current page (e.g. if you are in page 3, and submit a result from selects form, than all related items are displayed - not starting from page 1 but from page 3, which means something a fake "no results"). This is the classic function of render pager: echo $works->renderPager(array('arrayToCSV' => false)); Any idea? Thanks! Edit: I've also tried the "start=0" within the selectors, however it Always re-start from page 1 and stick to that, regardless. So no more option to move to page 2, 3, ....
  11. I was wondering how to achieve the following. A total of 100 pages which are listed with a limit of 10 items per page, resulting in 10 pages of 10 items. Instead i desire the following (below), and wondering how to setup the code / selector(s). The first page should show a list of 8 items. After that all following pages should have a limit of 10 items. page 1 -> items 1 - 8 -> (limit 8) page 2 -> items 9 - 18 -> (limit 10) page 3 -> items 19 - 28 -> (limit 10) ... page 9 -> items 79 - 88 -> (limit 10) page 10 -> items 89 - 98 -> (limit 10) page 11 -> items 98 - 100 -> (limit 10) The ideal situation would be to have an extra page selector property aside of 'limit', something named 'limit_first' or alike.
  12. Hello All, I have setup a blog and added pagination to it with Pager (Pagination) Navigation I have followed the Docs. However when I click on the next page the page just reloads but the blog posts do not change. news/?page=2 etc is added to the URL but the results stay the same any ideas? The code Iam using is below. Cheers Jon <?php $results = $pages->find("template=news-item|news-item-right-gallery, limit=2, sort=-news_date"); $pagination = $results->renderPager(); foreach($results as $result) {?> <div class="news-article"> <div class="row"> <div class="medium-3 columns"> <?php if($result->single_image) $large = $result->single_image->width(150); $small = $result->single_image->width(590); echo "<img data-interchange='[{$small->url}, small], {$small->url}, medium], {$large->url}, large]'>";?> </div> <div class="medium-9 columns"> <?php echo "<h2><a class='title' href='{$result->url}'>{$result->title}</a></h2>"; echo "<p class='published'><i class='fa fa-calendar' aria-hidden='true'></i> On - {$result->news_date}</p>"; if ($result->excerpt) { echo $result->excerpt; }else{ echo $result->body; } ?> <a href="<?php echo $result->url ?>" class="button small">Read More</a> </div> </div> </div> <?php } echo $pagination; ?>
  13. Good day! Suddenly I stumbled upon pagination once again. Pagination itself works as expected, but renderPager() returns the same markup on every paginated page. So it is 1st page current on every /pageN/. What can cause this? Please help.
  14. Hello, I'm new to PW and need some help. I created a simple gallery which is working fine, but I can't figure it out how to create some styling for pagination. I use this for pagination: <?= $a->renderPager() ?> My html look like this: <div class="numeric-pagination"> <a href="#" class="button"><i class="icons icon-left-dir"></i></a> <a href="#" class="button">1</a> <a href="#" class="button active-button">2</a> <a href="#" class="button">3</a> <a href="#" class="button"><i class="icons icon-right-dir"></i></a> </div> I hope you understand what I want to create. Thank you R
  15. Hi Guys This is possibly a stupid question but I can't get it to work. How can I limit the max number of pages I get and paginate them afterwards with a different limit(per pagination page)? Lets say I have a total of 1000 Events. I want to output 100 Events (10 Events per pagination page). // outputs 10 events per page but returns all 1000 events - how pagination works default $items = $pages->find("template=event, limit=10"); // should output 10 events per page but should only use the 100 latest events for output - doesn't work // Try 1 $items = $pages->find("template=event, limit=100")->find("limit=10"); // Try 2 $items = $pages->find("template=event, limit=10, getTotal=100"); // output pager echo $items->renderPager(); Can someone clarify that to me? Greetings Orkun
  16. Hello I am using a dynamically created Pagination like: $allImages = $page->VitrineImages; $limit = $page->VitrineImageCount; $start = ($input->pageNum - 1) * $limit; $images = $page->VitrineImages->slice($start, $limit); $total = count($page->VitrineImages); $a = new PageArray(); foreach($images as $unused) $a->add(new Page()); $a->setTotal($total); $a->setLimit($limit); $a->setStart($start); this works fine in the template file to create Pagination in relation to the number of images for that field in the page. But I have problems to include that inside a sitemap template (I am using the code from here -> https://processwire.com/talk/topic/3846-how-do-i-create-a-sitemapxml/?page=1 ) It doesn't create anything when I use the same code in the sitemap.php only replacing the $page variable with $homepage which is defined in _init.php (which is prepended for the sitemap template - and it's inside the $homepage page where I use the pagination in that way) It seems I am missing something (kind of new to processwire) because $a is always 0 when using this code in my sitemap.php file...
  17. TL;DR How to change a paginated URL so it reads "example.com/foo/2/" instead of "example.com/foo/page2/"? Excuse me if this is the wrong place to post this (in which case please move this to the right forum), or this has been asked before... but how do you remove the "page" prefix in a paginated url so that it reads something like "example.com/foo/1/" instead of the default of "example.com/foo/page1/"? I know that for any other type of prefix, I can just override $config->pageNumUrlPrefix in site/config.php, but I can't figure out how you'd do it if you simply want an effectively "blank" prefix. I've tried setting $config->pageNumUrlPrefix = '' but that ends up breaking pagination altogether or the page prefix ends up in the URL instead. The only way I can think of doing this is actually changing the line: if(!$pageNumUrlPrefix) $pageNumUrlPrefix = 'page'; to if(!$pageNumUrlPrefix) $pageNumUrlPrefix = ''; but tampering a module file seems bad practice and so I am looking for a better way to achieve this. Help a ProcessWire noob out!
  18. Hi all, I've just noticed a strange issue with some paginated pages on my site UKMoths, (http://ukmoths.org.uk). I have a series of pages showing thumbnails of moths by family, here: http://ukmoths.org.uk/thumbnails. The opening page shows the families but as you drill down, it displays all the species within a certain family. If there are more than 12 then the output is paginated using standard MarkupPagerNav functionality. On some however, I've noticed some long strings of random characters between the base url and the page notifier. For example the crambidae list has 140 species so has about 12 pages. Page 1 is fine, showing /thumbnails/crambidae, but pages beyond this, instead of the urls being like /thumbnails/crambidae/page2 they are something like /thumbnails/crambidae/BVXAz1div6cNWKM3P5NDP7EoP4WA .... (cut for brevity) ... CSCHd6.9c6Nhh/page2. I can't for the life figure out why this is happening. It seems to be the case for both ProCache version pages and non-cached (when logged in). If I look at the ProCache folder in the assets, the structure looks to be correct - i.e. a crambidae folder and then page2, page3 etc. folders. I should point out that the pages render correctly, even with these odd urls. It doesn't happen across the board though - it just seems to be certain ones - the /thumbnails/elachistidae folder pagination is fine - yet they're all using the same template. And the same site on my dev system is fine. Confused! Any one have any thoughts? Thanks, Ian.
  19. I'm just looking at trying to modify the output of the renderPager function. Instead of <li> for the page numbers, we need a select menu. Is it possible to modify the HTML that is returned or will I need to write my own function? Historically I would have used some form of override (Joomla) or inheritance to achieve this. What is the best way to 'build' on the PW core rather than rewrite it? What we're looking to achieve is have a dropdown rather than the intermediary numbers e.g. 1 ~ DROPDOWN ~ LASTPAGE
  20. Hi, I have some pagination on my page, which is pretty bog standard. $allChildren = $page->find('template=blog-article, limit=10, sort=-article_date'); The limit is set to 10 as I want to show them 10 articles at a time. The articles are displayed side by side, so there is 5 rows of 2 article. I am using infinite scroll plugin (which doesn't really matter). However the first article is a featured article and displays full width, so this leaves me with an odd article at the end. - - - (1) - - - - (2) - (3) - - (4) - (5) - - (6) - (7) - - (8) - (9) - - (10) So really I need the first page to show 11 and then on other pages for it to be 10. - - Page 1 - - - - - (1) - - - - (2) - (3) - - (4) - (5) - - (6) - (7) - - (8) - (9) - - (10) (11) - - - Page 2 - - - (12) (13) - - (14) (15) - - (16) (17) - - (18) (19) - - (20) (21) - - - Page 3 - - - (22) (23) - - (24) (25) - - (26) (27) - - (28) (29) - - (30) (31) - Is this possible? Any pointers would be much appreciated! Thanks, Craig
  21. Hi, Run into a bit of an issue with pagination on a site I am working on. I am sure the answer is really simple, but struggling to figure out what's going wrong. I have a bunch of articles, but I only want the ones where the date is less than the current date. I then want to limit the array so that I can paginate it. <?php $allNews = $page->children("template=news"); $oldNews = new PageArray(); foreach($allNews as $article) : if(strtotime($article->date) <= strtotime('now')): $oldNews->import($article); endif; endforeach; $oldNews = $oldNews->find('limit=2, sort=date'); echo $oldNews->renderPager(); foreach ($oldNews as $article) : ... endforeach; ?> The limit is being applied, however I don't see any pagination and navigation to the different pages returns the same first two articles. Any help would be much appreciated. Thanks, Craig
  22. One of my blogs seems to be accessible from multiple URLs and it's affecting my clients SEO. For example, using the following URL structures, I can access the same page. http://www.domain.not/blog/page2/ http://www.domain.not/blog/posts/page2/ The correct one is probably the second one as all posts are children of blog. My actual blog structure is as follows Blog - Posts -- Post A -- Post B -- Post C (etc) - Tags - Categories I have pagination enabled on a template called blog-posts which is applied to the Posts page. I'm not sure though why the double URL is occouring?
  23. Hi folks, I am using pagination on a news overview on my site. I have three queries set up on this page; a display first post, a display the next six (excluding the first) and then everything else (so excluding the first and the next six); so in theory the part I want to paginate starts at post 7 onwards. The only issue I have is when I click to the next page (page2) it shows the first post, the next six, then everything else, again. I understand why this is happening... it is using the same template for page2, page3 etc etc, which includes those queries. Below is my entire setup. Is there any way around this? I've tried using 'start' positions etc but doesn't seem to work properly. http://snippi.com/s/4ze4c4u (this is my entire setup for the news page) Any help or ideas? Many thanks.
  24. Full disclosure: I'm starting in ProcessWire after having used MODX almost exclusively for the last four or five years. I still tend to think in terms of the parameters that I can set in a function call and, frankly, my knowledge of php has degenerated thanks to every need pretty much being covered by the snippet library there. I am trying to familiarize myself with ProcessWire by coding a simple gallery site (to work my way up to more complex sites as I get more comfortable). I've been able to look up everything I need between the cheat sheet, wiki and the existing forum topics until today. I have finally stumbled into something I can't quite work out (and can't figure out keywords with which to search). Staging site, the gallery in question: http://www.creativejay.com/xine/portfolio/ (I haven't finished setting up fancybox, that's fiddly stuff for later) In the portfolio I have three albums currently. Since these galleries will only grow, I want to add pagination now. I understand how to paginate with MarkupPagerNav and find(), which is how I retrieve the albums themselves, but the individual images in the album are retrieved with a double scoop of foreach. Here's the entire code of my function at the moment: <?php function galleryMain(){ $albums = wire("pages")->find("has_parent=/albums/"); echo "<div class='albumgrid'>"; $out =""; foreach($albums as $album) { $albumimages = $album->gallery; $thumbsize = 140; foreach ($albumimages as $albumimage) { $out .= "<a href='{$albumimage->url}' title='{$albumimage->description}' class='fancybox-button' rel='fancybox-button'>"; $out .= "<img src='{$albumimage->size($thumbsize, $thumbsize)->url}' style='margin-right: 15px; margin-bottom:25px; border: solid 1px #000000;' height='{$thumbsize}' width='{$thumbsize}'>"; $out .= "</a>"; } echo $out; } echo "</div>"; } ?> So what's happening above (as I understand it) is that it's fetching the children of /albums/ which results in three albums. It runs through each one "as $album" and within that it runs through all the items in the album's $gallery field, then loops back and repeats for each album. If I add my pagination limit in the initial find() call, it's actually just limiting the number of albums display. Since my desired thumbnail limit is 30 per page and there are three albums this is moot (aside from not being what I want). If I were to limit within the "as $album" call, or deeper, would it not limit the items displayed from each album, but not necessarily result in pagination in the resulting web page that would lead me to additional pages of thumbnails? So my question is: What syntax (and where) do I use to paginate the code above to display a maximum of 30 gallery thumbnail images, total, from three albums per page? Ideally I'd also like to order them so that the newest images appear first, exclusive of what album they are from. I should note I'm following the gallery tutorial from the wiki and I am more than happy to use different code in my function entirely if it achieves the goal more directly. Thanks a bunch in advance!
  25. Let's say I have 500 Eventpages or more with differen content fields(date, title, textarea etc..). I would display all events in a list like this: $events = $pages->find("template=event, limit=10"); echo "<div class='event-container'>"; foreach($events as $event){ echo "<div class='event-detail'> <h1>$event->title</h1> <p>$event->short_description</p> </div>"; } echo "<a class='load-more'>LOAD MORE</a>"; echo "</div>"; Now I want to make the load-more link to display 10 or 20 more events without reloading the page and showing a loading gif/text while its rendering the other events, when clicking on it . How can i achieve this? I know that i could use pagination for displaying this heavy amount of results but the customer doesn't want that because it don't fit in the design of the website. Can I probably achieve a combination with Pagination and Ajax, or are there other ways to do it?