5

I'm currently using the following code for pagination:

{pagination_links}
    {page}
        <a href="{pagination_url}">{pagination_page_number}</a>
    {/page}
{/pagination_links}

Because of an addon I'm using, I need to modify the output of the {pagination_url} variable.

{pagination_url} outputs http://sitename.com/blog/P20, and I need to add a segment before blog.

I attempted to use the Find and Replace Plus addon, but due to the parse order, I'm not able to use the {site_url} variable to find/replace.

Is there an easier way to accomplish this?

13

If you just need to modify the part of the URL before the pagination segment (and your use case is relatively simple) you can use the paginate_base parameter on your entries loop (docs here):

{exp:channel:entries paginate_base="blog/foo"
  {pagination_links}
    {page}
        <a href="{pagination_url}">{pagination_page_number}</a>
    {/page}
  {/pagination_links}
{/exp:channel:entries}

Now your output should look like this: http://example.com/blog/foo/P20

2
  • I don't know how I overlooked that parameter, but this is exactly what I was looking for. Thanks!
    – Jon Horton
    Nov 26 '12 at 16:51
  • No problem, happy to help...
    – Tom Davies
    Nov 26 '12 at 16:58
1

If you're feeling brave, you can also head to:

system/codeigniter/system/libraries/Pagination.php

All of the opening and closing elements are there and you can override them. Just make a note of those changes so you can restore them after an upgrade.

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.