9 votes
Accepted

Check if paginate

The paginate.totalPages variable will give you the total number of pages that are generated by the paginate tag. So you can wrap your display of pages around a conditional that checks to see if this ...
Steve Rowling's user avatar
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

Paginate entries with offset / limit when templating

You could use Twig's Slice function. {% set firstTwo = paginatedEntries|slice(0,2) %} {% set lastFour = paginatedEntries|slice(2,4) %} Then loop over firstTwo for your first items. {% for entry ...
a-am's user avatar
  • 2,857
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

Modify ElementCriteria and use it for paginate

You can only modify a craft.entries criteria model with a field (→ Add custom element criteria attribute without a field type?). So what you have to do is to create a new custom field type with your ...
carlcs's user avatar
  • 36.2k
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,317
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

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

Using prevSiblingOf and nextSiblingOf

Those parameters are only meant to be used on entries within Structure sections. (Just updated the docs to make that more clear.) If you want to get the next/previous entries within a Channel section,...
Brandon Kelly's user avatar
4 votes
Accepted

Reverse count with paginated entries?

You already pass the array keys into the loop as a variable pageInfo. There's a couple of properties you can access from it, see the Craft docs: Templating Reference → {% paginate %} Of interest for ...
carlcs's user avatar
  • 36.2k
4 votes
Accepted

Paginate entries when I do not have a criteria model?

This is in no means an elegant solution, and can almost certainly be improved. But it did its job just fine. {% set veterinarians = craft.entries({ section: 'veterinarians', order: '...
carlcs's user avatar
  • 36.2k
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.2k
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.3k
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

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

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
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
Accepted

Combing an If Statement with Pagination

To get the pagination to work as expected, you need to incorporate the if into your craft.entries query. There may be a more elegant solution to do this, but looking at the database, the selected ...
André Elvan's user avatar
  • 7,278
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
  • 173
3 votes

Showing pagination for a date range of entries

It's difficult to give specific code help without seeing some input/output examples, but here's a go-by: You can say that an event occurs during a date range if: The event begins before the date ...
Michael Rog's user avatar
  • 3,400
3 votes
Accepted

Use paginate info in another block

As of Craft 2.5.2750, you can leave off the {% endpaginate %} tag, then move your {% paginate %} tag up outside of the blocks in the posts/index.twig template, and your pageInfo variable should be ...
Mike Pepper's user avatar
  • 4,391
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
Accepted

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

Not tested, but I would assume that you could simply get the total entries, divide by the pagination limit and then generate your dynamic nav using a range loop. {% set totalEntries = craft.entries....
Douglas McDonald'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

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

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

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,278
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

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