Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-01-11 21:16:57

alexandra
Member
From: Cologne, Germany
Registered: 2004-04-02
Posts: 1,370

ras_if_expired (conditional, expiration, date)

rsiletti wrote this neat plugin which is not listed here or on textpattern.org.

ras_if_expired
Download

<code><txp:ras_if_expired offset=“4”>
statement if 4 days or more have passed since the posting date
</txp:ras_if_expired></code>

Another example (expire file download links based on date) by arkham here.

Someone who could add that to textpattern.org?

Last edited by alexandra (2006-01-11 21:18:18)

Offline

#2 2006-08-20 14:04:23

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,304

Re: ras_if_expired (conditional, expiration, date)

It’s simply indispensable to any page containing announcements!

In the meantime Rick has changed it’s name to ras_if_days . The link above is broken, since yesterday it can be downloaded by clicking here. Help in the form of an explained code example is accessible after installation, and as long as it doesn’t have it’s own entry in textpattern.org [nope] take this bit of information from Rick’s textcastle.

Last edited by uli (2006-08-20 14:14:33)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#3 2006-08-21 00:51:00

nardo
Member
From: tuvalahiti
Registered: 2004-04-22
Posts: 743

Re: ras_if_expired (conditional, expiration, date)

uli, is it possible to use this plugin (with articles in an ‘events’ section) to get “what’s on today” ?

I have tried but failed!

Offline

#4 2006-08-21 02:16:20

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,304

Re: ras_if_expired (conditional, expiration, date)

yes, nardo, i think it’s possible. you left too few information for a tele-diagnosis. but i’ll try anyway.

first of all: you have installed it and turned it on? i sometimes forget about that. :/

then, in the extension help rick writes:
<code><txp:ras_if_days_not_passed offset=“7”></code>
<code><txp:ras_if_days_passed offset=“1”> </code>

[ … the code that creates your events-html comes here … ]

<code></txp:ras_if_days_passed></code>
<code></txp:ras_if_days_not_passed></code>

<code>This would return</code> [ … the code that creates your events-html comes here … ]
<code>for articles more than one day old and less than seven days old.</code>
<code>The offset attribute is numbered in days or fractions of days</code> (whatever he means by “fractions”)

well, you have to change these values a little as you need a time-window of one day. So the difference between the first and the second value needs to be exactly 1.
Now comes a bit of math you often enough will need a calender for, but for the moment i prefer a simple example: you have written the article on the 10th and it is to be published on the 27th. Then the value of the second offset of the example given above (ras_if_days_passed) should be 17, the first offset value (ras_if_days_*not*_passed) should be 18 (as the date of expiration has to be the 28th).

hope i didn’t mix things up and was clear enough.

something i haven’t tried yet but should also work and would be simpler by far:
set the article’s date in content&nbsp;>&nbsp;write to the date of publishing and use only ras_if_days_*not*_passed to let it expire.

and then tell us if it works! Thank you.

Last edited by uli (2006-08-21 03:14:53)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#5 2006-08-21 03:43:08

nardo
Member
From: tuvalahiti
Registered: 2004-04-22
Posts: 743

Re: ras_if_expired (conditional, expiration, date)

this is for an events listing … where articles are given a published date corresponding to the event date … ‘upcoming events’ is easily output using time="future" variable on article tag … ‘what’s on today’ is a feature I’d like to implement, that shows events whose published date corresponds to today’s date

so plugin installed and turned on! a bunch of dummy events posted today at various times (before and after current time) … and using <txp:article_custom time="any" section="events" form="ras" /> in the page template to generate the required list

the form ‘ras’ looks like this:

<code><txp:ras_if_days_not_passed offset=“1”>
<txp:ras_if_days_passed offset=“0”>
<txp:if_different>
<txp:posted format=”%A “ />
</txp:if_different>
<txp:permlink><txp:title /></txp:permlink><br />
</txp:ras_if_days_passed>
</txp:ras_if_days_not_passed></code>

no results, and kinda lost!

Offline

#6 2006-08-21 11:45:55

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,304

Re: ras_if_expired (conditional, expiration, date)

gees, i’m a beta and you let me take a look at the deepest innards. * faint * ;)
seems you simply copied the code from rick’s example. haven’t you got any ras_if_days-coded stuff to work ever? not even in it’s most basic version:

<code><txp:ras_if_days_not_passed offset=“7”></code>
<code><txp:title /></code>
<code></txp:ras_if_days_not_passed></code>

i mean, even throw out
<code><txp:article_custom time=“any” section=“events” form=“ras” /></code>

for me the above worked. If it likewise works for you, try adding other code line by line.

Last edited by uli (2006-08-21 11:57:35)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#7 2006-08-22 01:03:07

nardo
Member
From: tuvalahiti
Registered: 2004-04-22
Posts: 743

Re: ras_if_expired (conditional, expiration, date)

I have it working now, so that articles (‘events’) with a posted-date today (before or after current time) are shown AS WELL AS tomorrow’s … I couldn’t restrict to just today, but that’s not too bad

in page template: <dl><txp:article_custom section="events" time="any" form="ras" limit="999" sortdir="asc" /></dl>

the form ‘ras’:

<code><txp:ras_if_days_not_passed offset=“1”>
<txp:ras_if_days_passed offset=”-1”>
<txp:if_different><dt><txp:posted format=”%A %e %B” /></dt></txp:if_different>
<dd><txp:permlink><txp:title /></txp:permlink></dd>
</txp:ras_if_days_passed>
</txp:ras_if_days_not_passed>
</code>

Last edited by nardo (2006-08-22 01:03:52)

Offline

#8 2006-08-22 01:52:05

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,304

Re: ras_if_expired (conditional, expiration, date)

Nardo, are you able to reproduce which change did the trick? Maybe I’ll run into that problem at a later date.
I mainly recognize the difference in –1 at the end of the second line <code><txp:ras_if_days_passed offset=”-1”></code>


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#9 2006-08-22 03:21:58

nardo
Member
From: tuvalahiti
Registered: 2004-04-22
Posts: 743

Re: ras_if_expired (conditional, expiration, date)

yeah that’s about it !

altho there is the slight possibly I had a typo in one of the tags, but I don’t think so

time is complex, other issues may well arrive – I don’t think this is the definitive solution, but will give it a live test and report back in a month or so

Offline

#10 2006-08-26 21:58:24

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,304

Re: ras_if_expired (conditional, expiration, date)

in the meantime i’ve thought about a “one form for all”-solution and after not succeeding in transferring proposals i found in the forum, i got great help from mary from southern alberta ;) the outcome is the following piece of code:

<pre><code><•txp:php></code>
$vanishes = custom_field(array(‘name’ => ‘vanishes in__days’));

if (!$vanishes)
{ $vanishes = 9999;
}
$thing = ‘

simply paste the code here you’d like ras_if_days_not_passed to check

‘; echo ras_if_days_not_passed(array(‘offset’ => $vanishes), $thing);
<•/txp:php></code></pre>

to customize it to suit your needs do the following:
  • create a custom field in txp’s preferences.
  • replace “vanishes in__days” in the example above with this field’s name.
  • replacing my line “simply paste … to check” insert the txp-/html-code you’d like to be checked by ras_if_days_not_passed.
  • don’t forget to remove the two bullets from the txp-code

in cases you leave the custom field empty when editing an article, this snippet contains a carefree-function, that automatically sets the article to stay online for a bit more than 27 years (which should be fairly sufficient; if not, don’t hesitate to increase “9999” a little). This means, if you want an article to vanish after a certain date, set his lifespan to the value in days you want it to be read. If you want to publish an article like you always did, just do it that way, leave the custom field empty, and it will vanish not until mr gates and his operating system are retired.

btw, differing from the behavior of ras_if_days_not_passed called directly, mary’s code needs an increase of the entered value by 1 for reasons i don’t know anything about. that is, if you publish an article that shall exist exactly 24 h from the date of publishing, give it a “virtual” lifetime of two days. (yep, mr gates is retired in 9998 days accordingly.)

Last edited by uli (2006-08-26 22:30:26)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#11 2006-08-31 13:32:14

jayrope
Plugin Author
From: Berlin
Registered: 2006-07-06
Posts: 687
Website Mastodon

Re: ras_if_expired (conditional, expiration, date)

just thought i’d let you guys know about this:

Task:
Setting up a list of upcoming and today’s live dates in the left sidebar.
Preparation:
Each date is contained in one article. The article’s posting date is set to the future day and starting time of the event to be announced. Band name, club name, city name and admission fees are stored in custom fields named band, location, city and fee. No entry for country, people can use maps.
I installed the textpattern plugin ras_if_days.

Setup
I prepared two article forms:
live_single for upcoming dates, but not of today
<code>
<li><txp:if_different><txp:posted format=”%d.%b” /><br /></txp:if_different><txp:permlink><txp:custom_field name=“band” /> in <txp:custom_field name=“city” /> <txp:custom_field name="location" /></txp:permlink></li> </code> and ??live_single_today?? for today's dates <code> <li> <txp:ras_if_days_not_passed offset="1"> <txp:ras_if_days_passed offset="-1"> <txp:if_different><txp:posted format="%d.%b" /><br /></txp:if_different> <txp:permlink><txp:custom_field name="band" /> in <txp:custom_field name="city" /> <txp:custom_field name=“location” /></txp:permlink>
</txp:ras_if_days_passed>
</txp:ras_if_days_not_passed>
</li>
</code>

Then i put the following code into my left sidebar form,
a headline:
<code><h3>live</h3></code>
for today’s dates:
<code><txp:article_custom form=“live_single_today” limit=“5” category=“live-date” sortby=“Posted” sortdir=“asc” listform=“live_single_today” /></code>

and finally for all dates upcoming furthermore:
<code>
<txp:article_custom form=“live_single” limit=“10” category=“live-date” sortby=“Posted” sortdir=“asc” listform=“live_single” time=“future” />
</code>

Precautions
The plugin code works only when called from a form. It does not work when you try using it from the sidebar navigation directly, or from the content space in the section page code. Ask me why: I don’t know it.

I hope you find this useful. Please note, that i am a musician and therefore use code just when i have to. Therefore my answering your comments below might be sloppy, nevertheless i’d be glad if this helped.

Toooot!

j

this text can aswell be found on my textpattern tryout site

Last edited by jayrope (2006-08-31 13:33:38)


A hole turned upside down is a dome, when there’s also gravity.

Offline

#12 2006-08-31 17:36:55

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,304

Re: ras_if_expired (conditional, expiration, date)

jayrope:

Please note, that i am a musician and therefore use code just when i have to.

< txp:toooot /> :))


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

Board footer

Powered by FluxBB