Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: etc_pagination: paginate everything
It looks ok, but if you get only empty classes in <article class=""></article>, it means for me that <txp:custom_field name='Content_type' /> of displayed articles is empty, so nothing else is output. Could you add something, like <txp:title />, just before the first <txp:if_custom_field /> block to see what happens? You can also add <txp:newer/older /> tags inside <div id="newer-older" /> to see if they work as expected.
Offline
Re: etc_pagination: paginate everything
You are most likely correct Oleg, it’s a move from one template to another so its likely that there is nothing in the custom fields. I’ll investigate and report back.
Offline
Re: etc_pagination: paginate everything
Hi Oleg, yes you were correct that the issue was in fact that the custom field was empty and therefore nothing was being returned. Thanks for your help and this lovely little plugin! I’ll post a URL when the site is launched in the next day or two..
Offline
Offline
Re: etc_pagination: paginate everything
Hi Oleg, on a current site the pagination needed is from an article_custom tag, and much to my chagrin I saw that etc_pagination doesn’t work with article_custom, at least I don’t see anything in the plugin help text. Any chance its supported and I missed it?
Offline
Re: etc_pagination: paginate everything
Hi Jonathan, <txp:article_custom /> paginates very badly, but you can achieve it with a little help from etc_query (see here). Try to put this in your page form to paginate <txp:article_custom section="your_section" /> by 5:
<!-- count the pages -->
<txp:etc_query name="numPages" data="SELECT CEILING(count(*)/5) AS numPages FROM textpattern WHERE Status=4 AND Section='your_section'" />
<!-- navigation bar -->
<txp:etc_pagination pages='<txp:variable name="numPages" />' pgcounter="page" />
<!-- display the appropriate page -->
<txp:article_custom section="your_section" limit="5" offset='<txp:etc_query data="{?page|0|intval.-1.*5}" globals="_GET" />' />
Last edited by etc (2013-03-30 17:13:35)
Offline
Re: etc_pagination: paginate everything
Thanks Oleg – I’ve given it a first go but run across probably a simple problem to resolve. Heres the code I’m using:
<!-- count the pages -->
<txp:etc_query name="numPages" data="SELECT CEILING(count(*)/5) AS numPages FROM textpattern WHERE Status=4 AND Section='<txp:if_section name="news">news,blog,potw,six-innings<txp:else /><txp:section /></txp:if_section>'" />
<txp:article_custom section='<txp:if_section name="news">news,blog,potw,six-innings<txp:else /><txp:section /></txp:if_section>' offset='<txp:etc_query data="{?page|0|intval.-1.*5}" globals="_GET" />'>
....Article stuff here....
<txp:if_article_list>
<txp:if_variable name="numPages" value="">
<txp:else />
<div id="newer-older" class="text-center">
<txp:etc_pagination pages='<txp:variable name="numPages" />' pgcounter="page" prev="Previous" next="Next" range='<txp:adi_if_mobile>2<txp:else />10</txp:adi_if_mobile>' wraptag="" break="" />
</div>
</txp:if_variable>
</txp:if_article_list>
What I’m getting is no pagination output. Just the newer-older div. I’ve tried removing the <txp:if_variable name> block but that doesn’t work either. There is something in the etc_pagination call that is throwing it off.
Second issue is that the article_custom is now displaying 10 articles in an individual article page – that didn’t happen before. I guess I could add if_individual logic, but would like to understand why the etc_query tag in the article_custom call changes the output of articles….
Offline
Re: etc_pagination: paginate everything
Seems the variable is not being set properly:
<txp:if_variable name="numPages" value="">
[<txp:if_variable name="numPages" value="">: false]
<txp:etc_pagination pages='<txp:variable name="numPages" />' pgcounter="page" prev="Previous" next="Next" range='<txp:adi_if_mobile>2<txp:else />10</txp:adi_if_mobile>' wraptag="" break="" />
[attribute 'pages']
<txp:variable name="numPages" />
[<txp:variable>: Unknown variable 'numPages']
[/attribute]
[attribute 'range']
<txp:adi_if_mobile>
[<txp:adi_if_mobile>: false]
</txp:adi_if_mobile>
[/attribute]
[<txp:etc_pagination pages='<txp:variable name="numPages" />' pgcounter="page" prev="Previous" next="Next" range='<txp:adi_if_mobile>2<txp:else />10</txp:adi_if_mobile>' wraptag="" break="" />: false]
</txp:if_variable>
I got the article_list and individual pages sorted out, just used forms instead inside calls to article_custom and article. So now, its just list pagination.
Offline
Re: etc_pagination: paginate everything
Jonathan, etc_query uses the raw MySQL syntax for DB queries, so Section='news,blog,potw,six-innings' looks for the section literally named news,blog,potw,six-innings. Try to replace the first query by
<!-- count the pages -->
<txp:etc_query name="numPages"
data='SELECT CEILING(count(*)/5) AS numPages FROM textpattern WHERE Status=4 AND Section IN (<txp:if_section name="news">"news","blog","potw","six-innings"<txp:else />''<txp:section />''</txp:if_section>)' />
and then (without if_variable)
<txp:etc_pagination pages='<txp:variable name="numPages" />' pgcounter="page" prev="Previous" next="Next"
range='<txp:adi_if_mobile>2<txp:else />10</txp:adi_if_mobile>' wraptag="div" class="text-center" />
Edit: you’ll probably have to replace “six-innings” by “six\-innings”, but I am not sure.
Last edited by etc (2013-03-28 09:14:34)
Offline
Re: etc_pagination: paginate everything
Thanks Oleg! Looking great now – thanks for the instruction re the raw MySQL queries – its good to learn about this amazing little plugin you have written – thank you for that! There was no need to escape six\-innings – it didn’t work. six-innings was fine!
Offline
Re: etc_pagination: paginate everything
Glad you have it working, just call if something gets weird!
Slightly OT for devs: the first counting query would be unnecessary if <txp:article_custom /> supported pgonly attribute in some sense. For example, <txp:article_custom pgonly="numPages" /> could store the number of pages in <txp:variable name="numPages" />. I am not very hot about tight integration of article_custom pagination into etc_pagination, this would yield too much code replication.
Edit: or if <txp:article_custom pgonly="1" /> returned the number of pages…
Last edited by etc (2013-03-28 11:58:03)
Offline
Re: etc_pagination: paginate everything
Version 0.3.5: added new (undocumented, but self-explanatory) <txp:etc_numpages /> and <txp:etc_offset /> tags, to ease <txp:article_custom /> pagination. The problem above can be solved without etc_query now:
<!-- navigation bar -->
<txp:etc_pagination pgcounter="page"
pages='<txp:etc_numpages section="news,blog,potw,six-innings" limit="5" />' />
<!-- display the appropriate page -->
<txp:article_custom section="news,blog,potw,six-innings" limit="5"
offset='<txp:etc_offset pageby="5" pgcounter="page" />' />
You don’t need them for <txp:article /> pagination.
P.S. I still think that <txp:article_custom pgonly="1" /> would be better, so <txp:etc_numpages /> hopefully is only temporary solution.
Offline
Re: etc_pagination: paginate everything
Great! I’ll give it a shot later and report back. Thanks Oleg!
Offline
Re: etc_pagination: paginate everything
Ok Oleg – its working. Here’s what I had to do:
Page template:
<txp:article_custom section='<txp:if_section name="news">news,blog,potw,six-innings,photos<txp:else /><txp:section /></txp:if_section>' limit="10" offset='<txp:etc_offset pageby="10" pgcounter="page" />' form="news_list" />
Pagination form:
<div id="newer-older" class="text-center">
<txp:etc_pagination pgcounter="page" pages='<txp:etc_numpages section='<txp:if_section name="news">news,blog,potw,six-innings,photos<txp:else /><txp:section /></txp:if_section>' limit="10" />' prev="Previous" next="Next" range='<txp:adi_if_mobile>2<txp:else />10</txp:adi_if_mobile>' wraptag="" break="" />
</div>
Thanks a lot for this – much cleaner.
Offline
#30 2013-05-08 16:59:24
- uli
- Moderator

- From: Cologne
- Registered: 2006-08-15
- Posts: 4,319
Re: etc_pagination: paginate everything
Hi Oleg,
I’m trying to create prev/next links for a txp:article tag, ordered by position (the stm_article_order DB column) and would expect to have chosen the easier one of the two article tags and be able to alter some attributes and in this way somehow get me there. But I’ve no luck: the two examples taken from the help output nothing although I’ve placed them in the same form that the native prev/next tags work in.
Please nudge me in the right direction. (TXP is 4.5.4, etc_pagination is v0.3.5)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline