Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-10-14 19:27:34

korpulente
Member
Registered: 2009-01-29
Posts: 36

Pagination problem

I must be a total dork since I can’t figure this out, but please help me out.

What I need:
An unordered list displaying links to the latest articles in my news section. So far so good. However, I also need some pagination that enables the user to “go back” and get a list of the previous articles, before those shown up front.

My problematic code, inserted into a page:

<txp:if_article_list>
<txp:article_custom section="news" status="live" limit="9" form="news-links" sort="Posted desc" wraptag="ul" />

<a href="<txp:older />" class="prev-news">Older news</a>
</txp:if_article_list>

The article links show up correctly, but the pagination is flawed. The “Older news” link is shown at all times, even when it has no function, ie. when there are no older news to show.

What did I do wrong?

Offline

#2 2009-10-14 19:35:56

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Pagination problem

The older and newer tags provide pagination for the article tag. Unfortunately this doesn’t work with article_custom.


Code is topiary

Offline

#3 2009-10-14 19:52:52

korpulente
Member
Registered: 2009-01-29
Posts: 36

Re: Pagination problem

Ouch… Can I achieve a functionality like the one I tried to make with article_custom, without this tag?

Offline

#4 2009-10-14 20:36:22

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Pagination problem

Is this list to appear only in the news section and/or on the home page, or is it to appear in other sections? If it’s only for the news section you can simply use article instead of article_custom. For the home page you could do likewise but only if news is the only section whose articles you want on the home page (or if you don’t mind articles from a mix of sections in this list). If it’s to appear in all sections you will have to use article_custom, in which case you could paginate with javascript, or a plugin such as chh_article_custom which works with pagination.


Code is topiary

Offline

#5 2009-10-14 20:56:08

korpulente
Member
Registered: 2009-01-29
Posts: 36

Re: Pagination problem

I need to display the list in multiple sections.

One acceptable workaround is to just show the pagination in the news section, which could then use article, and then use article_custom to pull in into the other sections.

However, it still doesn’t work:

<txp:article form="news-col" status="live" limit="9" wraptag="ul" />

 <txp:if_article_list> 
 <a href="<txp:older showalways="0" />" class="prev-news">Older news</a>
 </txp:if_article_list>

The damn pagination link is displayed at all times. :-/

Offline

#6 2009-10-14 21:15:01

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Pagination problem

korpulente wrote:

it still doesn’t work

It’s working all right ;) showalways="0" just doesn’t work if you use the <txp:older /> tag like that. You’ll have to use Example 1, or use variable and if_variable to check for content.

BTW, showalways="0" is the default value, so you can leave it out.

Offline

#7 2009-10-14 21:21:49

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Pagination problem

You don’t need to specify showalways="0", because that is the default. Is there another article tag on this page?


Code is topiary

Offline

#8 2009-10-14 21:49:07

korpulente
Member
Registered: 2009-01-29
Posts: 36

Re: Pagination problem

Yes of course it’s working, but I’m not able to have it do things my way. :-)
I’ll look in to variable and if_variable. Doesn’t make much sense to me at first glance.

jsoo wrote:

You don’t need to specify showalways="0", because that is the default. Is there another article tag on this page?

Yes there is one.

Offline

#9 2009-10-14 21:58:01

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Pagination problem

If older is unexpectedly producing links to, say, ?pg=2, it is probably because of the other article tag.


Code is topiary

Offline

#10 2009-10-14 22:08:55

korpulente
Member
Registered: 2009-01-29
Posts: 36

Re: Pagination problem

I just tested it and you’re absolutely right. I need the other article on that page though. Is there a way to tie older to a specific article — maybe by using variable?

jsoo wrote:

If older is unexpectedly producing links to, say, ?pg=2, it is probably because of the other article tag.

Offline

#11 2009-10-14 22:29:34

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Pagination problem

Ah OK, my suggestion to use variable and if_variable was supposed to solve this:

The damn pagination link is displayed at all times. :-/

but apparently your problem is a different one (as Jeff found out). Can you post both your article tags please? I’m not sure, but maybe the pageby attribute could help.

Offline

#12 2009-10-14 22:52:59

korpulente
Member
Registered: 2009-01-29
Posts: 36

Re: Pagination problem

First one is to display the latest news article fully:

<txp:article limit="1" />

Next, I need a column with links to a series of the nine latest news articles:

<txp:article form="news-col" status="live" limit="9" wraptag="ul" />

 <txp:if_article_list> 
 <a href="<txp:older" />" class="prev-news">Older news</a>
 </txp:if_article_list>

This article uses this form, to produce the list:

<li><txp:posted format="%e. %b." /> <txp:permlink><txp:title /></txp:permlink></li>

Thank you so much for helping me out, by the way! Much appreciated.

Offline

Board footer

Powered by FluxBB