2

I'm breaking my head over this one. maybe it's pretty simple, and am i just being blind. however, something is not going right with pagination. On the homepage we want to display general info, a content slider, and the lates 5 projects, with a pagination for the older projects.

All things are parsed nicely, except when it comes to the pagination. When i call the homepage(www.domain.com) the pagination is not working. I see the pagination buttons, but the items are allways the same, the latest 5. However, if i call www.domain.com/site/index, everything works the way it should.

{exp:channel:entries channel='algemene_teksten_nl' limit='1' dynamic="no" url_title='home'}
{embed='_inc/.header' pagetitle='{algemene_teksten_nl_browsertitle}' pagedescription='{algemene_teksten_nl_description}'
}
{/exp:channel:entries}
{embed="_inc/.home-boxes"}

And the embed is

{exp:channel:entries channel="projecten_nl|boxes_nl" status="not niet-op-home" limit="5" paginate="bottom" paginate_base="/" dynamic="no"}
<h2>{if channel_short_name == "projecten_nl"}{box_title}{if channel_short_name != "projecten_nl"}{title}{/if}</h2>
{paginate}
            {pagination_links}
                <ul class="pagination">
                    {page}
                        <li{if current_page} class="current"{/if}><a href="{pagination_url}">{pagination_page_number}</a></li>
                    {/page}
                </ul>
            {/pagination_links}
        {/paginate}
{/exp:channel:entries}

And oh yeah, i'm on 2.5.5...

  • Do the links output correctly (e.g., /P5, /P10, etc)? – Derek Hogue Jan 31 '13 at 13:34
  • What happens if you move the code into the main template? – fccotech Jan 31 '13 at 18:47
  • @DerekHogue yes they do – Jelle Dijkstra Jan 31 '13 at 21:22
  • @fccotech doesn't matter if i use it in an embed, or in the main template... – Jelle Dijkstra Jan 31 '13 at 21:23
  • 1
    pagination_base="" Overrides EE's built in functionality to use the current url structure to use for pagination and use the specified template for pagination. So if you are currently on example.com/template_group/template_name and trying and specifying pagination_base="/" you would need to make sure that in your sites index template you have the logic for your pagination. – Justin Long Jan 31 '13 at 21:36
1

I wanted to expand a bit on my earlier comment but couldn't edit it so here I go.

The pagination_base parameter allows you to specify a specific template that will be used for pagination oppose to the default behavior of EE which would be to use the current URL. A perfect example of when you might want to use this would be if you had a blog (with the url structure domain.com/blog/articles) and on the homepage you wanted to show 5 of the most recent articles. Lets say that you want to then have the viewer directed to your paginated entries if they wanted to view more articles from your blog. So in your template you would have soemthing along the lines of:

{!-- Homepage template snippet --}
{exp:channel:entries channel="blog" limit="5" paginate="bottom" pagination_base="blog/articles"}
<a href="{url_title_auto_path}">{title}</a>
{custom_field}

{paginate}
{pagination_links}
    <ul class="pagination">
        {page}
            <li{if current_page} class="current"{/if}><a href="{pagination_url}">{pagination_page_number}</a></li>
        {/page}
    </ul>
{/pagination_links}
{/paginate}
{/exp:channel:entries}

This would allow the user to view the 5 most recent articles then when they clicked on the pagination link the page that would be loaded would be domain.com/blog/articles/P5. For that template to actually load the next set of articles you would need to have the following:

{!-- blog/articles template snippet --}
{exp:channel:entries channel="blog" limit="5" paginate="bottom" }
<a href="{url_title_auto_path}">{title}</a>
{custom_field}

{paginate}
{pagination_links}
    <ul class="pagination">
        {page}
            <li{if current_page} class="current"{/if}><a href="{pagination_url}">{pagination_page_number}</a></li>
        {/page}
    </ul>
{/pagination_links}
{/paginate}
{/exp:channel:entries}

Since we are already on blog/articles we no longer need to add pagination_base="blog/articles as EE will default to that since it is in the URL.

Another example of when you would possibly want to use pagination_base would be in the event that you are wanting to load your entries via AJAX and dont want to add the weight of loading your entire template. A while back I wrote an article on my blog about implementing an (infinite-scroll script) where I used the pagination_base parameter.

  • Hi Justin, thanks for your extensive reply. however, taking the paginate_base out of it doesn't make it magically work, unfortunately. – Jelle Dijkstra Feb 1 '13 at 7:51
  • Did you also remove dynamic="no"? Also if you have your paginated entries tag in a conditional such as {if segment_1 == ""} you will need to use something like switchee to still display it when there is PXX in the URL – Justin Long Feb 1 '13 at 8:21
  • yes, with or without dynamic=no still the same. i am using switchee, so first i test if paginated or empty, and a simple {if segment_1 == 'P5'} paginated{/if} does show paginated when on /P5. {exp:switchee variable = "{segment_1}" parse="inward"} {case value="#^P(\d+)$#|''"} The strange thing is, when i go to /site/index/P5 everything works as it should (when not using switchee offcourse) – Jelle Dijkstra Feb 1 '13 at 8:50
  • Jelle and i exchanged some tweets about this, i'm convinced there is some issue in his setup. Even the most basic channel:entries tag pagination doesn't work in his case. – GDmac Feb 1 '13 at 10:16
  • i allready re-uploaded some of the key system files, emptied caches, etc – Jelle Dijkstra Feb 1 '13 at 10:32
0

i figured it out. i had Zoo triggers installed. i wasn't using it, but in the output profiler i saw it did get called. i had to de-install it completely, but the issue was gone...

guess i'll be back soon for some help with categories and archives....

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.