1

I want to avoid duplicate titles/descriptions on pages (P1,P2...) so I want to add Page 1, Page 2 in the page title.

Is there a way to know if we are on pagination and which page it is, but outside of pagination tags? Maybe Stash or something like that?

Thank you

3

I wrote a plugin a while back to do this. It was the first one I wrote so apologies in advance if it's not up to scratch.

Example is included in the plugin usage, but basically, place {exp:page_number url_segment="{segment_1}" limit="5"} somewhere in your template.

Parameters:

url_segment: the segment which contains your page number
limit: the same value you have in your channel entries tag which limits the number of entries shown per page

| improve this answer | |
  • could you elaborate on how we could use your plugin to achieve the desired result ? ( some sample code f.ex ) – janvl Nov 28 '12 at 8:36
  • I knew there was some plugin for this so I will give it a try. thanx – Davor Peic Nov 28 '12 at 12:59
2

With Stash, inside you pagination tag pair you could do:

{paginate}
    {exp:stash:set name="page_number"}
        Page {current_page}
    {/exp:stash:set}
    {!-- any other pagination stuff here --}
{/paginate}

Which would give you "Page X" accessible as {exp:stash:get name="page_number"}.

Another potential is to use Mo' Variables, which provides a Pagination Detect Conditional and Page Offset as {if paginated} and {page_offset}, respectively.

So for example

{if paginated}This is a paginated view{/if}

But I just realized {page_offset} isn't going to be quite what you wanted. It will give you some multiple of whatever you have in your limit parameter so will not directly give you "Page 1" "Page 2" etc.

| improve this answer | |
  • Thank you! at the moment I don't use Stash, but if the plugin will not be enough, this will be my next solution. – Davor Peic Nov 28 '12 at 13:01
  • I bet the plugin by @Tyssen will be just what you need. – Alex Kendrick Nov 28 '12 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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