Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: etc_pagination: paginate everything
Hi Uli,
You could try etc_link_to to replace link_to_prev/next tags. etc_pagination is not working in individual article mode, you can see it rather as enhanced txp:older/newer tag.
And as ever, if you only need to replace some attributes of existing tags, etc_query will do it nicely.
Offline
#32 2013-05-10 12:28:45
- uli
- Moderator

- From: Cologne
- Registered: 2006-08-15
- Posts: 4,319
Re: etc_pagination: paginate everything
etc wrote:
etc_paginationis not working in individual article mode
D’oh, of course! Thanks, Oleg. I’ll post a comment on the etc_link_to page of your website.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: etc_pagination: paginate everything
Hi! Thanks for this awesome plugin. I need some help:
Now I get this output
<ul class="pagination">
<li><span data-rel="current">1</span></li>
<li><a href="#">2</a></li>
<li><a data-rel="next" rel="next" href="#">Next</a></li>
</ul>
but I need to style it differently, numbers and text. So I want this output:
<ul class="pagination">
<li class="current"><span class="page-number">1</span></li>
<li><a class="page-number button" href="#">2</a></li>
<li><a class="page-next" href="#">Next</a></li>
</ul>
How could I achieve that?
Thank you in advance.
Offline
Re: etc_pagination: paginate everything
Thank you, most of it goes to ob1_pagination. I thought data-rel attributes would suffice for styling, but your question definitely makes sense. The current version is not flexible enough to produce such an output, but the (quickly tested, but unofficial) dev latest version is:
<txp:etc_pagination wraptag="ul" class="pagination" current="class='current'"
link="<a class='page-number button' href='{href}'>{*}</a>,<span class='page-number'>{*}</span>"
next="<a class='page-next' href='{href}'>Next</a>"
>
<li {current}>{link}</li>
</txp:etc_pagination>
I have to test yet whether it is fully compatible with previous version, but it should be safe to use. If you don’t mind testing immature code, your feedback will be greatly appreciated.
Last edited by etc (2014-06-19 08:34:35)
Offline
Re: etc_pagination: paginate everything
Thank you for your answer Oleg! And: It works perfectly!!!
I think it is much simpler to customize the output.
By the way: is it possible to do this:
<div class="pagination-info">Page 1 of 3</div>
Thank you for your time and help!
Last edited by robhert (2013-09-23 13:43:12)
Offline
Re: etc_pagination: paginate everything
robhert wrote:
By the way: is it possible to do this:
<div class="pagination-info">Page 1 of 3</div>
Thanks for testing! For <txp:article /> pagination, you can try
link='<div class="pagination-info">Page {*} of <txp:php>global $thispage; echo $thispage["numPages"];</txp:php></div>'
This is not very practical, so I could introduce some {pages} placeholder in the next version, thank you for the suggestion. Meanwhile, you can simply add $replacements['{pages}'] = $numberOfTabs; right after the replacements array definition in the code, and call
link='<div class="pagination-info">Page {*} of {pages}</div>'
Offline
Re: etc_pagination: paginate everything
Hi Oleg! First, thank you for your time.
I added in the line 124 this:
$replacements['{pages}'] = $numberOfTabs;
In context:
$replacements['{link}'] = strtr($last ? $last : $link, $replacements);
$replacements['{pages}'] = $numberOfTabs;
if($gap2 && $loopEnd < $numberOfTabs)
And I put this on my page:
<txp:etc_pagination link='<div class="pagination-info">Page {*} of {pages}</div>' />
And I got this:
<span data-rel="current"><div class="pagination-info">Page 1 of {pages}</div></span>
<a href="?q=hi&pg=2"><div class="pagination-info">Page 2 of {pages}</div></a>
Any idea? Did I made something wrong?
Thank you in advance.
EDIT 1: Tried the other code
<txp:etc_pagination link='<div class="pagination-info">Page {*} of <txp:php>global $thispage; echo $thispage["numPages"];</txp:php></div>' />
But get this:
<span data-rel="current"><div class="pagination-info">Page 1 of 2</div></span>
<a href="?q=hi&pg=2" rel="" data-rel=""><div class="pagination-info">Page 2 of 2</div></a>
Last edited by robhert (2013-09-23 19:48:40)
Offline
Re: etc_pagination: paginate everything
Hi Robhert,
line 124 is too late, add this code after l. 36. For the rest, that’s what I meant by testing the compatibility with the previous version. :) Could you try this:
<txp:etc_pagination link='<div class="pagination-info">Page {*} of {pages}</div>'>
{link}
</txp:etc_pagination>
or even
<txp:etc_pagination>
<div class="pagination-info">Page {*} of {pages}</div>
</txp:etc_pagination>
Edit: well, we’ll have to do something with the current page. What is working now is:
<txp:etc_pagination link='<div class="pagination-info">Page {*} of {pages}</div>' current='<div class="pagination-info">Page {*} of {pages}</div>' active="1">
{link}
</txp:etc_pagination>
but it’s too heavy.
Last edited by etc (2013-09-23 20:08:06)
Offline
Re: etc_pagination: paginate everything
Hi Oleg! It didn’t work. And I think the plugin is fine in what it does: paginating articles.
BTW, I found a TXP plugin what does what I need: rsx_page_number
Thank you very much for your help and time!
Offline
Re: etc_pagination: paginate everything
robhert wrote:
<div class="pagination-info">Page 1 of 3</div>
Sorry, Robhert, I guess I have misunderstood your question. If you want to output the current page number separately from the nav list, this should do:
<div class="pagination-info"><txp:php>global $thispage; echo "Page $thispage['pg'] of $thispage['numPages']";</txp:php></div>
It will work only for <txp:article /> pagination, so I should probably add few new tags to etc_pagination to enable it in other lists.
Edit: ok, quickly implemented in dev version now, please test:
<div class="pagination-info">Page <txp:etc_offset type="counter" /> of <txp:etc_numpages /></div>
Last edited by etc (2013-09-24 09:25:51)
Offline
Re: etc_pagination: paginate everything
It works!!!
Your plugin is awesome! I’ve installed the dev_version and added <div class="pagination-info">Page <txp:etc_offset type="counter" /> of <txp:etc_numpages /></div> to my code and the output is <div class="pagination-info">Page 1 of 3</div>.
Thank you Oleg!
Last edited by robhert (2013-09-24 14:52:57)
Offline
Re: etc_pagination: paginate everything
Version 0.4 released as beta for the moment, more functional and flexible, please welcome. It incorporates Robhert’s suggestions and more, but is not fully compatible with v.0.3, so test before use. For example, the output above can be obtained with
<txp:etc_pagination range="0">
<div class="pagination-info">Page {*} of {pages}</div>
</txp:etc_pagination>
Last edited by etc (2013-10-02 09:44:53)
Offline
Re: etc_pagination: paginate everything
Hi Oleg!
It seems this code won’t work with the newest version of your plugin because there is no active tag.
<txp:etc_pagination wraptag="ul" class="pagination" active="class='current'" link="<a class='page-number button' href='{href}'>{*}</a>" current="<span class='page-number'>{*}</span>" next="<a class='page-next' href='{href}'>Next</a>">
<li {active}>{link}</li>
</txp:etc_pagination>
What I need is this
<span class='current'>1</span>
<a href='#' class='page larger'>2</a>
<a href='#' class='nextpostslink'>»</a>
But I don’t know how to get that ouput. I tried many times, and the only code that partially works is this:
<txp:etc_pagination link="<a class='page larger' href='{href}'>{*}</a>" current="<span class='current'>{*}</span>" prev="<a class='prevpostslink' href='{href}'>«</a>" next="<a class='nextpostslink' href='{href}'>»</a>">
{link}
</txp:etc_pagination>
Works, but there is no current page selection (All links are active).
Could you give me a hand with this?
Thank you very much.
Robhert
Offline
Re: etc_pagination: paginate everything
Hi Robhert,
yes, there are few changes (whence my warning), but you are almost there:
<txp:etc_pagination link="<a class='page larger' href='{href}'>{*}</a>,<span class='current'>{*}</span>"
prev="<a class='prevpostslink' href='{href}'>«</a>" next="<a class='nextpostslink' href='{href}'>»</a>"
>
{link}
</txp:etc_pagination>
should be ok. Each “link” attribute (like link, next and so on) can come in two states now: general,special; and the current attribute plays the role of ex – active (gone). For example, if you want to show some “next” text even on the last page, you can put
next="<a class='nextpostslink' href='{href}'>»</a>,<span class='nextpostslink'>»</span>"
Sorry for somewhat cowboyish plugin help, I hate wtfm.
Last edited by etc (2013-10-08 21:00:30)
Offline
Re: etc_pagination: paginate everything
Thank you Oleg! Works like a charm!
Offline