5

I am having some issues with pagination.

I have two channel entries loops on one template, both of which have pagination enabled.

One of the loops works fine but the second one, I guess is conflicting.

For example.. the second loop is duplicating the pagination segments in the url

domain.com/P1/P2 etc..

(I am also using this from Aaron Bushnell)

Is it even possible to work them independently on one template? Thanks!!

  • 2
    Just to be clear, when a pagination link is clicked/pagination segment is in the URL, do you want both channel:entries tags to be affected in the same way? (ie that domain.com/P10 should offset both entries by 10), or to have independent pagination for each? – Tom Davies Dec 5 '12 at 12:14
  • Did any of the answers help you? If yes, please mark the answer correct by clicking on the checkmark to the left of the answer. – Anna_MediaGirl Dec 22 '12 at 6:26
3

Try wrapping each channel entries and each pagination in a conditional. If the pagination layout is identical for each channel entry section then you can throw it in a snippet. It might look something like this:

{if segment_2 == "pancakes"}
{exp:channel:entries channel="pancakes"}
    {title}
    {sn-pagination}
{/exp:channel:entries}

{if:elseif segment_2 == "waffles"}
{exp:channel:entries channel="waffles"}
    {title}
    {sn-pagination}
{/exp:channel:entries}
{/if}
  • Hi Stuart, thanks for your help. It's a single page website so there are no segments to check against. I was using the jQuery to paginate without refreshing the page. – Mark Dec 8 '12 at 16:38
3

I would do the same as Stuart McCoy, but performance wise it's better to use switchee instead of the native advanced conditionals.

{exp:switchee variable = "{segment_2}" parse="inward"}

{case value="pancakes"}
    {exp:channel:entries channel="pancakes" dynamic="off"}
      {title}
      {sn-pagination}
    {/exp:channel:entries}
{/case}

{case value="waffles" default="Yes"}
    {exp:channel:entries channel="waffles" dynamic="off"}
      {title}
      {sn-pagination}
    {/exp:channel:entries}
{/case}

{/exp:switchee}

don't forget to add the dynamic="off" param!

  • Yeah, switchee would definitely be better. I was writing on my iPad on the train to work and I didn't want to over complicate the general solution which would be to split the two into separate conditionals and see if pagination still breaks. – Stuart McCoy Dec 5 '12 at 15:36
  • 2
    I am not sure if this is what Marc is looking for. I think he is looking for a way to have two entry loops with coexistent paginations on one page. Managing multiple pagination URL segments is the difficulty here. – Dennis Frank Dec 5 '12 at 17:09

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.