Skip to main content
9 votes

Using pagination on a page with url with query string data

In most Craft projects I do I'll create a pagination include file so anything I need that requires pagination, I can just include that and I get the same pagination pattern anywhere within my site ...
Tim Knight's user avatar
  • 1,022
6 votes
Accepted

Getting the last X number of pages in pagination

As I already wrote in my comment 3 days ago something like this should work {% paginate craft.entries.section('mySection').limit(10) as pageInfo, pageEntries %} {% for page, url in pageInfo....
Robin Schambach's user avatar
5 votes
Accepted

Check paginated currentPage before setting the paginate tag

Ok, so after discovering the getPageNum request, I found the following solution: {% set pageNumber = craft.request.getPageNum %} {% set firstPageLimit = 5 %} {% set defaultLimit = 8 %} {% set limit =...
Mark Notton's user avatar
  • 2,337
5 votes

{% paginate %} Tag issue, no prevUrl / nextUrl Data

You need to set a limit on your element query, so Craft knows how many entries you want per page: {% paginate craft.entries.section('newsBlog').limit(1) as pageInfo, pageEntries %} If you don't set ...
Mats Mikkel Rummelhoff's user avatar
5 votes
Accepted

Pagination and Entry Model on Homepage

project.images is an array because you are eager-loading the images. Since you’re only loading one project entry, you’re not actually gaining anything by eager-loading the images (or category), ...
Brandon Kelly's user avatar
4 votes
Accepted

Excluding a single Entry ID of an Entry Type from craft.entries

You'd have to add a conditional and render the featured entry on the first paginated page only. You can access that info from the pageInfo variable. Another thing I'd do is to remove the featured ...
carlcs's user avatar
  • 36.3k
4 votes

Any examples of numeric pagination?

Good starting point: https://craftcms.com/docs/templating/paginate If you also want display '...' instead of the whole list of page numbers, you can do something like this: {% if pageInfo.totalPages ...
Simon Franzen's user avatar
4 votes
Accepted

provide a 'back' or 'cancel' or 'close' button to return to whatever page that particular template was accessed from

You could use the Cookies plugin to store the last visited URL before the user hits one of the "step" templates, i.e. by putting something like the following in every template where the links to the "...
Mats Mikkel Rummelhoff's user avatar
4 votes
Accepted

Including Zii in Craft CMS

Craft 2.x ships with a subset of the Yii framework files with things like zii and Yii widgets stripped out. If you wanted to utilize them, you'd have to create a Craft plugin and manually include the ...
Brad Bell's user avatar
  • 67.5k
4 votes

Pagination with randomly ordered entries

Why is this happening? Why am I seeing duplicates? When the database is told to sort by random, the entire list of entries is being sorted into a random order before your required page of items is ...
missmatsuko's user avatar
4 votes

Order entries by a category field alphabetically then paginate

In order to sort your entries by a related field you need to join the relations and the content table and sort your entries by the column you want. The it doesn't change the behavior of your paginate ...
Robin Schambach's user avatar
3 votes
Accepted

Using pagination on a page with url with query string data

The huge advantage of craft over other CMS is the high flexibility and the ability to customize many things. Thus Craft won't provide non changeable <a> tags but links you can change like you ...
Robin Schambach's user avatar
3 votes
Accepted

Only fetch structure entries that are first level or sub level that don't have a parent

You can use the hasDescendants() method to filter out any parent entry with children. You have to use an ElementCriteriaModel with .getPrev() and .getNext(). {% set entries = craft.entries.section( '...
Luke Pearce's user avatar
  • 3,863
3 votes

provide a 'back' or 'cancel' or 'close' button to return to whatever page that particular template was accessed from

If you need to set a correct link on the cancel buttons than using browser history is the easiest way. {% if entry is defined %} // Going to STEP2 <button onclick="window.history.go(-1); ...
Dominik Krulak's user avatar
3 votes
Accepted

Check which pagination page to display code outside of pagination loop

UPDATED/EDIT ANSWER: If you only want to show the entries on the first page you should make an if statement to check if you are on the first page for your Featured Items by requesting the page number....
Justin Dekkers's user avatar
3 votes
Accepted

Eager-load and pagination

with is just another query param, like limit or whatever parameters you’re defining in entryParams. The {% paginate %} tag requires that you pass in an ElementCriteriaModel, but as soon as you call ...
Brandon Kelly's user avatar
3 votes

How to link to previous/next entries in a section?

For navigating siblings in a structure there's a shortcut: {% if entry.prevSibling %}<a href="{{ entry.prevSibling.url }}">Previous</a>{% endif %} {% if entry.nextSibling %}<a ...
Tamlyn's user avatar
  • 183
3 votes

Pagination base URL - any way to have pagination links go to URLs other than current one?

Since version 3.1.28, you can set base URL of pagination links, like this: {% paginate query as pageInfo, pageEntries %} {% do pageInfo.setBasePath('new_url') %}
Piotr Pogorzelski's user avatar
3 votes

Cache and Pagination not working

Based on the code you posted on pastebin, it seems like the problem is that you have your pagination outside of the cache tags (assuming this was the case when you had caching implemented). And, I'm ...
André Elvan's user avatar
  • 7,288
3 votes
Accepted

Graphql total results / pageinfo when searching with pagination

Try entryCount. You can also add arguments to this, such as section: entryCount(section:"news"), for example.
Chris Clower's user avatar
3 votes
Accepted

How to increase control panel pagination item count?

This has been asked before quite recently, and I don't believe there's been a better solution posted since then. Check out the answer on that post to see the solution, which involves using a bit of ...
Martin Spain's user avatar
  • 1,519
2 votes
Accepted

Paginate Grouped Entries

That error is occurring at entries.limit(10), because at that point entries is already an array of fetched entries, rather than an ElementCriteriaModel. (The entries will get fetched as soon as the ...
Brandon Kelly's user avatar
2 votes
Accepted

Paginate children in a structure

There are many ways to paginate: To show next / prev links #1 getPrevSibling getNextSibling {% if entry.getPrevSibling %} <a href="{{entry.getPrevSibling.url}}">{{entry.getPrevSibling....
Krzysztof Boduch's user avatar
2 votes
Accepted

filtering entries by category

You don't actually need to look at the URL segments, because Craft automatically populates your template with a category variable whenever it matches the current URL to a category's URL. All you need ...
Mats Mikkel Rummelhoff's user avatar
2 votes
Accepted

pagination showing all entries

When you use {% paginate %}, the second variable that's returned, pageEntries, is the paginated entries. When you do craft.entries.section('news').featured('not 1') later in the template, you're ...
André Elvan's user avatar
  • 7,288
2 votes

How do I get Pagination to Work?

A couple of years later, I ran into the same issue. In case there are others looking, it looks like this line: {% for page, url in paginate.getPreviousUrls(5) %} Should be: {% for page, url in ...
sonoflee's user avatar
2 votes

Add page number to Title and meta desc

You'll need to add more details about your current setup for a more specific answer. In general, adding a number to the Meta Title and Meta Description is probably not a good approach to solve your ...
Ben Parizek's user avatar
  • 13.5k
2 votes

Order a paginated entry by postDate

The code above is correct and working properly. There was a conflict with a masonry js file making the Craft ordering not work. Big thanks to @Anubarak for testing the code on their side.
Jon Livingston's user avatar
2 votes

Paginate a matrix

Found the answer - I had to paginate the children of "inhoud". Works like a charm now :-) {% for inhoud in entry.getDescendants() %} {% if inhoud.type == 'segment' %} <...
Jan's user avatar
  • 363
2 votes
Accepted

Allowing the user to update a CraftCMS pagination limit with listing filter options

You could create a form/a link with the limit and add the parameter in your $_GET request or as a segment to your url. This is just an example how to use it. How many Entries would you like to get? &...
Robin Schambach's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible