Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-07-09 09:44:45

coleh
Member
From: Edinburgh, UK
Registered: 2007-08-16
Posts: 28
Website

article_custom and pagination

Hey all

That dreaded question that has seemingly cropped up on the forums again and again.
Now the likely cause of this is that I have approached the problem wrong but was wondering if there was a solution to my approach or if it would be altogether preferable to just take a new approach altogether.

Premise is thus. I have a site with an Events (called events) section and want to differentiate between future and past events.
I have created a category called Diary (called diary) which will provide the context to trigger an article request for future events and a child category of diary called Past Events (called past-events) which will trigger an article request for – you guessed it – past events.

Now we all know article_custom can’t work with newer/older or ob1_pagination but if I use plain old article to generate an article list using a form then it can’t seems to show future or past events because of the contextual search it thinks that I am searching against articles featuring the category diary or past-events.
Have I just been a tool in the approach I’ve taken?

Devising sub-sections of a site by using categories is probably not the sharpest of solutions but it is the only way I could see of creating a sub-navigation to trigger different article requests. I can get the articles I want using article_custom (basically the same request against the events section but calling future and past articles (each event is an article) depending on the category – diary or past-events – called) but I cannot get these to paginate.

Anyone suggest how I might

  1. improve my approach, or
  2. get pagination to work with article_custom

Have I made something relatively straightforward really complicated?
Am I missing something obvious?
Should I consider getting involved in a land war in Asia?

Cheers in advance my dears,

Cole


Jack of all trades, Doctor of one

Offline

#2 2009-07-09 10:28:18

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

Re: article_custom and pagination

An idea — an ugly hack, but might work. Put this directly above the article tag that you want to ignore category context:

<txp:php>
global $pretext;
$pretext['c'] = '';
</txp:php>

Would be a good idea to restore $pretext['c'] immediately afterwards.


Code is topiary

Offline

#3 2009-07-09 10:36:10

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,611
Website

Re: article_custom and pagination

Instead of using a category, how about appending a custom variable to the link, e.g. ?archive=1 then using one of adi_gps / rah_if_gps / smd_if / chs_urlvar to test if the url variable exists and if so to output txp:article with time="past" (or however you’re doing it) and reverse the sort order.

If you don’t mind hacking in a special case into the htaccess, you can neaten the url so that you get /events/ normally and /events/archive/ for the archive:

RewriteRule ^events/archive/?$ index.php?s=events&archive=1 [L]

This is how I used to do it in the days before the expired timestamp existed.

Last edited by jakob (2009-07-09 10:43:09)


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB