Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-10-24 02:33:40

bokane
Member
From: Beijing, China
Registered: 2005-10-24
Posts: 13
Website

Articles for a given date range

I just started working for an organization that sends out a weekly email newsletter. Their old newsletter requireda lot of hand-formatting in an HTML editor and took about as long to get looking right as it did to write. I’m setting up Textpattern to store articles, and was wondering if there were a way of getting it to display content based on fairly specific date instructions – say, “everything between October 14 and October 21,” or “everything added since last Friday.” If Textpattern could archive files like that – i.e., in Friday-to-Friday chunks – that’d be absolutely ideal.

Any way of doing this? Thanks in advance…

Offline

#2 2005-10-28 23:43:53

aesop1
Archived Plugin Author
Registered: 2004-09-19
Posts: 142

Re: Articles for a given date range

Hmm. That’s a tough one. May need a plugin solution. You can fake the range, however, by just creating a category to “stand in” for the particular date range you want. Then you would just select that particular category for a date range.

Offline

#3 2005-10-29 01:11:11

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Articles for a given date range

I’d say a plugin too, using categories could very quickly become too much to handle.

Offline

#4 2005-10-29 05:45:28

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: Articles for a given date range

Wrote a quick conditional tag that looks like this:

<code>
function ras_if_expired($atts,$thing)
{ global $thisarticle; extract(lAtts(array( ‘offset’ => ‘14’, ),$atts)); $offset = $offset * 86400; $condition = $thisarticle[‘posted’] <= (mktime() – $offset) ? true : false; return parse(Evalelse($thing, $condition));
}
</code>

This checks (true/false) for the number of days(set by offset) passed since a posting was made. It wouldn’t take much( just change <= to >= in the test statement) to create a tag that would check for a number of days set to pass before a posting is considered current; a combination of the two might give you what you need.

Offline

#5 2005-10-29 11:46:46

RenJonsin
Member
From: Tarpon Springs, FL USA
Registered: 2005-02-06
Posts: 103
Website

Re: Articles for a given date range

I need something just like this. Do I paste this into the tag handlers file then just use the ras_if_expired tag with the offset attribute in my coding?

edit: corrected a typp

Last edited by RenJonsin (2005-10-29 11:48:12)

Offline

#6 2005-10-29 17:38:59

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: Articles for a given date range

You can download the function in a plugin from <a href=“http://textcastle.com/file_download/25”>download link </a>, and install it as a plugin; that way you can upgrade around it without having to hack Taghandlers at each new install.

If you needed both variations of the conditional you could copy ras_if_expired inside the plugin edit screen, change the name to something like if_current and change the test statement. From there you could use the combination of both tags to bracket posting dates. (having tried this myself, I found it extremely confusing. I’ve updated the download link to a file that includes both functions and a link to an explanation in an article posting). It works for me.

The functions look like this:
<pre>
function ras_if_expired($atts,$thing)
{ global $thisarticle; extract(lAtts(array( ‘offset’ => ‘14’, ),$atts)); $offset = $offset * 86400; $condition = $thisarticle[‘posted’] <= (mktime() – $offset) ? true : false; return parse(Evalelse($thing, $condition));
}

function ras_if_current($atts,$thing)
{ global $thisarticle; extract(lAtts(array( ‘offset’ => ‘14’, ),$atts)); $offset = $offset * 86400; $condition = (mktime() – $offset) <= $thisarticle[‘posted’] ? true : false; return parse(Evalelse($thing, $condition));
}
</pre>

and an exlpanation of how to use them is <a href=“http://textcastle.com/article/interesting-variations”>Here</a>

Last edited by rsilletti (2005-10-29 23:01:30)

Offline

#7 2005-11-01 01:19:59

RenJonsin
Member
From: Tarpon Springs, FL USA
Registered: 2005-02-06
Posts: 103
Website

Re: Articles for a given date range

Thanks! I will put this to use right away. Thanks for taking the time to do this.

Ren

Offline

Board footer

Powered by FluxBB