Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-05-23 19:56:22

Jeffrey
New Member
Registered: 2006-05-23
Posts: 6

Articles between two dates?

I am in the process of rebooting a site with TXP. One section of my site includes a bibliography with references to several hundred newspaper and journal articles related to the topic of my site. I plan to create an individual TXP article for each of these entires in my bibliography, so that I can use keywords to display bibliographic references related to specific articles in other sections of my site.

For the complete bibliography, I want to list the entries in chronological order (which I am able to do by setting the date of each bibliography article to its publication date or by using a custom field like 1976_12_22 for the article date).

My problem is that I don’t want all of the articles to display on a single page. I would like all of the articles from 2001 to 2005 to appear on their own page, all of the 1996-2000 articles to appear on another page, and so on.

Is there a way to specify a range of dates using a standard TXP tag or plugin tag? Or specify that articles before or after a certain date be listed? I’ve searched the FAQ, forums and TextBook to no avail.

Thanks in advance for any assistance.

Last edited by Jeffrey (2006-05-23 19:57:43)

Offline

#2 2006-05-24 02:52:32

april19
Member
From: Sydney, Australia
Registered: 2006-03-15
Posts: 27
Website

Re: Articles between two dates?

Wilshire might have what you’re looking for at his plugin page.

Offline

#3 2006-05-24 03:22:45

Jeffrey
New Member
Registered: 2006-05-23
Posts: 6

Re: Articles between two dates?

april19 wrote:

Wilshire might have what you’re looking for at his plugin page.

Thanks, I did look at these plugins, especially rss_suparchive, but as far as I can tell this does not allow you to specify a date range (e.g. 1977-1980) and display only the articles in that range on a page.

I can solve my problem by creating an additional keyword or using a custom field (e.g. “bib1” for the articles I want on the first Bibliography page, “bib2” for the next page, and so on) but there are two reasons I would prefer not to do this:

1) It seems redundant, since all of the necessary information is already included in the article date.

2) If I want to change the date ranges for these pages later on (e.g. I want to have three years displayed on each page instead of four) then I would need to go back and change the keywords or custom fields on dozens, if not hundreds, of articles.

It seems that there should be a way to use PHP to grab the article’s year and use a conditional statement to display the article if the year is between two specified values. Unfortunately I’m very new to TXP and only know a tiny bit of PHP, but if there’s no easier way to do this, I guess this might provide the incentive to learn both quickly!

Offline

#4 2006-05-24 04:29:46

Jeffrey
New Member
Registered: 2006-05-23
Posts: 6

Re: Articles between two dates?

OK, I think I may have solved my own problem. If I use the month attribute of the custom_article tag like so:

<code>
<txp:article_custom limit=“100” sortby=“Posted” sortdir=“asc” month=“1980” />
<txp:article_custom limit=“100” sortby=“Posted” sortdir=“asc” month=“1981” />
<txp:article_custom limit=“100” sortby=“Posted” sortdir=“asc” month=“1982” />
</code>

and so on, each of these lines will cause all of the desired articles from a single year to display. Since I only want 4 or 5 years per page, this shouldn’t be too cumbersome to implement.

I imagine there might be a more elegant solution, but this seems to do the trick. My only concern is that I am misusing the month attribute since it is supposed to be equal to something of the form “1980-05” (which would yield on the articles from May 1980). Simply using the year seems to make TXP treat the month as a wildcard.

Last edited by Jeffrey (2006-05-24 04:30:36)

Offline

#5 2006-05-24 15:34:57

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

Re: Articles between two dates?

That’s a nice discovery! Something to keep in mind. I wouldn’t worry too much about misusing the attribute if I were you, if it works, it works ;)

Offline

Board footer

Powered by FluxBB