12 votes
Accepted

Any examples of numeric pagination?

Sure, http://buildwithcraft.com/docs/templating/paginate {% paginate craft.entries.section('blog').limit(10) as entries %} <a href="{{ paginate.firstUrl }}">First Page</a> {% if ...
  • 428
10 votes
Accepted

Troubleshooting paginated content cached globally

I ran into this today. I thought craft.request.path used to include the pagination page number but it doesn't appear to anymore. Maybe it was always like this though. Regardless, this is how I'm now ...
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 ...
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 ...
  • 1,022
7 votes
Accepted

Sensible way to have different number of entries on page one of pagination?

There's an offset parameter that allows you to skip the first entries from your ElementCriteriaModel. You would set up two nearly identical ElementCriteriaModels, one exclusivly for your featured ...
  • 35.9k
6 votes
Accepted

Exclude category from channel entries (with pagination)

The without filter converts your ElementCriteriaModel into an array of entry models (the same as find() does). But that array won't work with paginate, as explained in the docs: This parameter ...
  • 35.9k
6 votes

How do i setup ajax paging for entries

Thanks to Kieth for posting an ajax solution. I just wanted to expand on it a little bit to figure out when we are at the end of the entries etc so we can hide loading more buttons etc. Here is what I ...
  • 801
6 votes
Accepted

Paginate an array with multiple filters

Try using this (completely untested): {% if paginate.prevUrl %} <a href="{{ paginate.prevUrl }}?{{ craft.request.getQueryStringWithoutPath() }}">Previous Page</a> {% endif %} {% if ...
  • 66.5k
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....
5 votes
Accepted

Use different template for paginated entries

I don't know if there's a route way to handle this, but you could do a conditional on the craft.request method getPageNum() like so: {% if craft.request.getPageNum == 1 %} <!-- Header for the ...
  • 35.9k
5 votes
Accepted

How do I create pagination links for my entry index page?

You have your {% for %} and {% paginate %} tags in the reverse order. You need to wrap the loop and the pagination URLs with the {% paginate %} tag pair: {% paginate craft.entries.section('houseRules'...
5 votes
Accepted

Search Results Pagination with multiple form fields

To get this working, you will need to find a way to continue passing all of your form’s values to each of the additional pages. There are a few ways you could do that, but the easiest and best option ...
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 ...
  • 35.9k
5 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 ...
  • 2,717
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 ...
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), ...
4 votes

Get value from dropdown and use in Twig

Twig (and all php) is processed server-side before javascript even gets initiated. And once the page renders in the browser there no way to interact directly with twig. The only two options that you ...
4 votes
Accepted

Paginate Entries by Day

Instead of using pagination, you might try creating a custom route using tags for year/month/day. Those tags will be available as variables in the template that you can use to load that days entries ...
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 ...
4 votes

Exclude category from channel entries (with pagination)

The probably more elegant way to handle this is to not use the without filter at all and simply list the categories you want to exclude prefixed with not. {% set categories = craft.categories({ ...
  • 35.9k
4 votes
Accepted

Pagination / Custom Routes (Based on Entry Existing)

For generating the nav, this should work. {% set allEntriesByWeek = allEntries|group("postDate|date('Y-W')") %} {% for week, entry in allEntriesByWeek %} <li><a href="events/{{ week|...
4 votes

Using ajax with routes is it right?

Sure, you can do something like {% if not craft.request.isAjax() %} {% redirect siteUrl %} {% endif %}
  • 4,519
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,...
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: '...
  • 35.9k
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 ...
  • 35.9k
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 ...
  • 35.9k
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 ...
  • 66.5k
4 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 =...
  • 2,275
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 "...
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 ...

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