Take the 2-minute tour ×
ExpressionEngine® Answers is a question and answer site for administrators, end users, developers and designers for ExpressionEngine® CMS. It's 100% free, no registration required.

RE: Pagination outside of channel entries tag?

Is this really the best way to place the pagination links outside the Channel entries tag? It seems ugly.

(And out of curiosity: is there a benefit to putting paginate inside the Channel entries tag? I'm wondering why EE was designed this way.)

Also, is there a way to control what is added to the URL segment? Say I wanted to change "P1", "P2", etc. to something else? What if I wanted it to be query string? I will paginating through search results and would like the GET param values in the URL.

UPDATE 1:

Trying the Stash solution, I did this:

// Inside the tag pair
{exp:stash:set name="pagination"} 
    {paginate}
        <p>Page {current_page} of {total_pages} pages {pagination_links}</p>
    {/paginate}
{/exp:stash:set}

And the later on in the same Stash template file:

{exp:stash:get name="pagination"}

This approach results in two things that I do not want:

  1. The pagination still shows inside the tag pair
  2. The pagination does not show outside the tag pair

EDIT 2:

This solved my Stash problem: https://gist.github.com/1206694

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

That's one way of doing it. You could also output the entire pagination-tag to Stash and then output it in the template somewhere else (see the examples @ Github).

share|improve this answer
add comment

Is this really the best way to place the pagination links outside the Channel entries tag? It seems ugly.

IMHO, it is indeed the best way. Plus, it's always a good idea to use the {if count == "1"} and {if count == total_results} conditionals because it keeps all of your template code that relates to a particular query self-contained.

(And out of curiosity: is there a benefit to putting paginate inside the Channel entries tag? I'm wondering why EE was designed this way.)

Because EE is much more than just the Channel Entries tag (i.e., other modules may well use the same URL-indicator for pagination), and you can have multiple Channel Entries tags within a single template. There would be no way for EE to know what it was paginating if the pagination code wasn't within the loop.

Also, is there a way to control what is added to the URL segment? Say I wanted to change "P1", "P2", etc. to something else? What if I wanted it to be query string?

In a word, no - not with the Channel or Search modules. You could use a third-party search module that does keep search and pagination information in the URL though (like Super Search or Low Search).

As a side note - remember that the first-party modules that come with EE are not frameworks - they are complete modules, designed to work a certain way. Some of them may provide many hooks to alter their behaviour, but they should, for the most part, be used as designed.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.