There was a need to detect if the page you are on is a “paginated” page, so I made a plugin. (And subsequently beefed it up with some suggestions in another thread, see below).
The forum thread that started all this: Detecting a single entry using EE code.
Working fine for me on a build right now. You can get the latest version here: MD Detect Page Type.
Sample Usage:
Super Basic Example:
{exp:md_detect_page_type url_segment="{segment_3}"}
{if pagination_page}This is a Paginated Page{/if}<br />
{if category_page}This is a Category Page{/if}<br />
{if yearly_archive_page}This is a Yearly Archive Page{/if}
{/exp:md_detect_page_type}
Basic Template:
{exp:md_detect_page_type url_segment="{segment_3}"}
{!-- if segment_3 is empty or it equals P## --}
{if pagination_page || segment_3 == ""}
{!-- list all the entries with pagination --}
{exp:weblog:entries weblog="weblog" paginate="bottom" limit="999"}
<h2>{absolute_count}. {title}</h2>
<p>{custom_field}</p>
{paginate}
<div class="pagination">
<p>Page {current_page} of {total_pages} pages. {pagination_links}</p>
</div>
{/paginate}
{/exp:weblog:entries}
{!-- otherwise, segment_3 has something in it
and it is not pagination. Show single entry --}
{if:else}
{exp:weblog:entries weblog="weblog" limit="1"}
{if no_results}<p>Sorry! Couldn't find that entry.</p>{/if}
<h2>{title}</h2>
<p>{custom_field}</p>
{/exp:weblog:entries}
{/if}
{/exp:md_detect_page_type}
If you use this and find any weird cases that I may have missed, let me know.
Add: A thread called “Can’t get pagination to work” deals with this pagination issue using PHP.
