I'm a beginner to EE and I'm looking for a way to add "" to any paginated pages in a Blog template in EE.

Is there any way to check in header if it's a paginated page and, if so, display this tag?



Ideally you don't want to lock your code to a specific segment and also for better performance comparing existing variables is better than running a regular expression.

My best recommendation, albeit a bit overkill just for this one conditional is to use the brilliant Mo' Variables plug-in, mainly because it adds loads more variables that are really useful to your build and obviouly make your code more readable...

{if paginated}

Assuming you have a page of content (entry_id) for the listing page, you could use this comparison:

{if url_title == last_segment}
   {!-- This is the first page (not pagination) --}
   {!-- This is a paginated page --}

If the page only contains listed entry_id's, you could use this conditional:

{if last_segment ^= "P"}
   {!-- This is a paginated page --}

...Although this assumes that the template used hasn't got a segment already that starts with a capital P!

Checking for any above page one (obviously this only works inside the {paginate} tag pair)...

{if current_page > 1}

The official documentation suggests this:

{if segment_3 ~ "/^P\d+/"}paginated{/if}

But I'd try to opt for this version instead:

{if last_segment ~ "/^P\d+/"}paginated{/if}

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.