Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2005-08-18 12:28:37
- TheUsability
- Member
- Registered: 2005-05-03
- Posts: 51
Getting Pagination to work with Offsets
Hi,
I’m using this code on my homepage to integrade Google ads into the content, using newer / older below to generate pagination:
<code>
<txp:if_article_list>
<txp:article form=“someform” limit=“2” sortby=“Posted” sortdir=“desc” listform=“excerpt” />
<txp:output_form form=“googlead” /><txp:article form=“someform” limit=“4” offset=“2” sortby=“Posted” sortdir=“desc” listform=“excerpt” />
<txp:output_form form=“googlead” /><txp:article form=“someform” limit=“4” offset=“6” sortby=“Posted” sortdir=“desc” listform=“excerpt” />
</txp:if_article_list>
<txp:if_individual_article>
<txp:article /></txp:if_individual_article>
<txp:if_article_list>
<p style=“text-align:right;”><txp:newer>Newer</txp:newer> <txp:older>Older</txp:older></p>
</txp:if_article_list>
</code>
The thing is, after using this offset, the posts on the second, third etc. page are totally messed up, starting wrongly. Pagination is screwed. What do I do wrong?
Big thanks for any quick help, since this is the last showstopper for me before going totally 4.0 :),
_TU
Offline
Re: Getting Pagination to work with Offsets
It may be because you are trying to use 3 article tags. Keep the first one but try changing the second and third to article_custom instead.
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
#3 2005-08-19 10:36:26
- TheUsability
- Member
- Registered: 2005-05-03
- Posts: 51
Re: Getting Pagination to work with Offsets
Nope, that’s not it. With article_custom, pagination is still screwed up (also, I can’t get the correct article form to be displayed…).
_TU
Offline
#4 2005-08-19 19:46:31
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Getting Pagination to work with Offsets
Textpattern does not know which article set you want to paginate. Use zem_nth rather than hacking it it yourself. :)
bc..<txp:if_article_list>
<txp:article limit=“10” sortby=“Posted” sortdir=“desc” form=“excerpt” /> <p style=“text-align: right;”><txp:newer>Newer</txp:newer> <txp:older>Older</txp:older></p><txp:else />
<txp:article /></txp:if_article_list>
at the end of the excerpt form
<txp:zem_nth step="2,4"><txp:output_form form="googlead" /></txp:zem_nth>
Offline
#5 2005-08-19 20:15:46
- TheUsability
- Member
- Registered: 2005-05-03
- Posts: 51
Re: Getting Pagination to work with Offsets
So far so good: I had a hunch that I wasn’t able to pull this off without zem_nth grr.
My problem now is that I don’t use a single form to style the posts on the homepage (i.e. in this example: form “excerpt”), but several different forms (I style by section like form “news”, form “tipps” etc.)
So with zem_nth at the end of form xyz, the ads only appear every 2nd and 4th xyz post in this example. What I need is every 2nd and 4th of EVERY post on the homepage. Can I use zem_nth in the default page template (i.e. within txp:article)? Where?
Last edited by TheUsability (2005-08-19 20:23:32)
Offline
#6 2005-08-19 21:24:05
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Getting Pagination to work with Offsets
I’m not sure I understand what you mean. Can you not use zem_nth (as I’ve shown) in every form you want it? Please elaborate.
Offline
#7 2005-08-19 21:28:28
- TheUsability
- Member
- Registered: 2005-05-03
- Posts: 51
Re: Getting Pagination to work with Offsets
I got a homepage that’s made out of posts that can have 5 different forms (it’s totally random). When I use zem_nth in one form, it only works every nth post in that specific form, right? But I want it every nth post on the homepage, no matter what form the post has. You getting me?
Last edited by TheUsability (2005-08-19 21:28:59)
Offline
#8 2005-08-19 21:33:28
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Getting Pagination to work with Offsets
So, are these override forms or what? Can you show them?
Offline
#9 2005-08-19 21:34:35
- TheUsability
- Member
- Registered: 2005-05-03
- Posts: 51
Re: Getting Pagination to work with Offsets
Yep, override forms.
Offline
#10 2005-08-19 22:10:33
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Getting Pagination to work with Offsets
You’re stuck using some PHP then. It’s a mite messy, but it works.
Above your first call to <txp:article />
, put in the page:
At the bottom of each of the forms in question, put:
<pre><code><txp:php>global $google; $google++; if ($google == 2 or $google == 4) echo output_form(array(‘form’ => ‘google’));</txp:php></code></pre>Offline
#11 2005-08-19 22:37:37
- TheUsability
- Member
- Registered: 2005-05-03
- Posts: 51
Re: Getting Pagination to work with Offsets
mary,
many thanks. but I guess before I start hacking in PHP, I do something else: get rid of the silly use of override forms. I currently just use them to get a different Tagline per section post, but I also can do that via a little logic in the default form (via if_article_section).
Now my question: Is there a way to get rid of all the override form-selections in old posts, i.e. one (or two) nifty sql lines? Help is appreciated since I don’t like to lose the override forms by hand with about 1000 posts :)
Last edited by TheUsability (2005-08-19 22:38:20)
Offline
#12 2005-08-19 22:41:12
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Getting Pagination to work with Offsets
Some sql in phpMyAdmin? Sure its possible. I’d need to know what you want to change “from” and “to”. :)
Offline