ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Add trailing slash and #content to pagination link urls

December 21, 2010 10:44am

Subscribe [4]
  • #1 / Dec 21, 2010 10:44am

    Oh My

    8 posts

    Hello!

    The EE pagination function adds pagination links nicely, but now I’m working on a project where I want the link urls to end with (for example): “.../P20/#content” thus making the browser jump down to the content div on the new page that is displayed after clicking on a pagination link.

    Is it possible to accomplish this somehow?

    Thanks!
    Johan

  • #2 / Dec 22, 2010 3:29am

    John Henry Donovan

    12339 posts

    Johan,

    I am moving this thread to the CodeShare Corner as it is more appropriate there.

    Have a look into the Low Replace add-on which would allow you to add something to the end of the URL

  • #3 / Feb 03, 2011 8:43am

    FountainInternet

    53 posts

    I just wanted to add that the Low Replace plugin is very useful in rewriting pagination URLs for other purposes. For example, if you need to enable query strings in your EE site (perhaps because member confirmation emails contain links with query strings in), you end up with pagination links turning into things like this:

    <a href="http://mydomain/segment1&per_page=P5">http://mydomain/segment1&per_page=P5</a>

    Supposedly this behaviour can be overridden with the page_query_string parameter, but it seems there may be a bug with it, and the parameter is ignored. However, you can work around this bug by using Low Replace and changing the {pagination_links} tag to the following:

    {exp:low_replace find="[\\/]*&per_page=(P[0-9]+)|/&per_page=" replace="/$1/|" regex="yes" multiple="yes"}{pagination_links}{/exp:low_replace}

    (Note that the above gives you a trailing slash in the new URL: if you don’t want a trailing slash, omit the second slash in the replace text.)

    You can also use Low Replace to localise the pagination link text and URLs.

    Simon

  • #4 / Jul 26, 2011 2:09am

    Matt Stein

    110 posts

    Many thanks for that second snippet, FountainInternet!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases