4

The "paginate" loop within the channel:entries tag used to render even when no next or previous links would need to render. This seems like it may have been "fixed" in response to a bug report here: http://expressionengine.com/bug_tracker/bug/11298/.

Unfortunately, this change this leaves no way that I can find to test to see whether pagination is without resorting to PHP in my template. PHP does seem to solve the problem but I wondered if anyone else has a way to do this with native EE code.

3
  • Can you post your PHP that currently works? One option is to convert that to a simple plugin. If it's simple, I will whip it up real quick for you using pkg.io. – Justin Kimbrell Nov 15 '12 at 20:51
  • In the ExpressionEngine forum, I discussed this and with some help got the code in this link: expressionengine.com/forums/viewthread/229324/#1040036 – John Morton Nov 15 '12 at 23:14
  • I have not implemented this code yet though. I'm probably going to need to do that in the next few days. I've just been looking for a native solution if possible. – John Morton Nov 15 '12 at 23:16
5

This should work:

{exp:channel:entries limit="10"}
{if count == 10}
{!-- we actually got 10 so we know there could potentially be more --}
{embed="embeds/paginate" offset="10"}
{/if}
{/exp:channel:entries}

And then the paginate embed:

{exp:channel:entries offset="{embed:offset}" limit="10"}
{if count == total_results}
YES WE DO HAVE PAGINATION
{/if}
{paginate}blabla{/paginate}
{/exp:channel:entries}

Of course, it's superhacky and ugly and you should use AB Pagination instead ;-)

5
  • 1
    I will use AB Pagination. I like it! It's a great add on. I just didn't know if it would help since the tags seems to exist within the EE paginate loop. :-) – John Morton Nov 16 '12 at 18:28
  • If you were to go down the route of not using AB Pagination then you may be better off setting a {preload_replace} variable for your 'limit' so that you can more efficiently manage it. – Mutual Nov 18 '12 at 14:34
  • Hi Bjørn. I did try AB Pagination today. It seems to have the same issue with this problem. Since it's tags all exist within the paginate loop, they don't render in this situation either. I think I'm going to go for the "superhacky" solution. Thanks! – John Morton Nov 18 '12 at 17:13
  • John, I wasn't aware of that ... I will have a look and see if it is possible to do something about. What is your use case here, if you don't mind sharing? – Bjørn Børresen Nov 21 '12 at 9:27
  • It's hard to describe without showing you the actual page (still in non-public developer at the moment) but I have more than just "next" and "prev" in my paginate tag. My pages end up missing vital pieces of the page structure when nothing renders in the paginate tag pair, like on an archive page for a year of blog entries that don't trigger a next or prev link. – John Morton Nov 28 '12 at 23:36

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.