Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-07-15 16:47:04

swf
Plugin Author
From: Saskatoon, Saskatchewan Canada
Registered: 2004-06-21
Posts: 109
Website

swf_section_updated

I created this plugin for a class website with a section that does not often get updates. I wanted the students to know when I added a tip to the tips section. swf_section_updated will check to see if a section has been updated in the past ‘n’ days. If the section has been updated, a message will be displayed.

Not sure if anyone else will need this but I thought I would offer it up anyway.

  • Attributes:
    • section choose the section you want to check for updated.
    • message This is the message you want to display if the chosen section has been updated in the previous n days. The default value is <code><sup>updated</sup></code></dd>
    • offset This is the number of days you want to display the message. If offset is not set, the default is 1 day.
  • Examples:
    • <code><txp:swf_section_updated /></code> With no attributes, the tag will return <sup>updated</sup> if the default section has been updated in the past day (24 hours).
    • <code><txp:swf_section_updated section=“about” /></code> With the section attribute set, this tag will display the default message if a new article has been created in the about section in the past day (24 hours).
    • <code><txp:swf_section_updated section=“about” offset=“5” /></code> With the section attribute set, this tag will display the default message if a new article has been created in the about section in the past five days.
    • <code><txp:swf_section_updated section=“about” offset=“5” message=”<em>new!</em>” /></code> With the section attribute set, this tag will display new! if a new article has been created in the <strong>about</strong> section in the past five days.

Info: Homepage
Download: Download plugin

Offline

#2 2005-07-15 18:49:37

creativesplash
Member
From: Coimbatore, India
Registered: 2005-01-19
Posts: 283
Website

Re: swf_section_updated

This is way too cool! I’ve been waiting for this for a loong time! Thank you very much!

p.s. Can you enhance this plugin by adding an attribute for “class” ? I would like to display the message as an image (bg. image inside a class).


“Take a point, stretch it into a line, curl it into a circle, twist it into a sphere, and punch through the sphere.”

— Albert Einstein

Offline

#3 2005-07-15 19:05:04

swf
Plugin Author
From: Saskatoon, Saskatchewan Canada
Registered: 2004-06-21
Posts: 109
Website

Re: swf_section_updated

I’ll see what I can do. i just had my wisdom teeth removed yesterday so I’m not my sharpest right now and I’m leaving for a week on Sunday. I’ll try to find time before I leave. I’ll just have to look at some other plugins with a class attribute to see how that works.

Offline

#4 2005-07-15 19:44:50

swf
Plugin Author
From: Saskatoon, Saskatchewan Canada
Registered: 2004-06-21
Posts: 109
Website

Re: swf_section_updated

I think I have it working, I’ve just put it in a span so if class is set then it will wrap the message in a <code>span class=“class”>message</span></code>.
I’ll call it version 1.1 and upload it. Let me know if it works for you

Offline

#5 2005-07-15 19:49:15

igner
Plugin Author
Registered: 2004-06-03
Posts: 337

Re: swf_section_updated

take a look at doTag() and doWrap()… for an easy way to handle these kinds of attributes.


And then my dog ate my badger, and the love was lost.

Offline

#6 2005-07-15 21:10:39

swf
Plugin Author
From: Saskatoon, Saskatchewan Canada
Registered: 2004-06-21
Posts: 109
Website

Re: swf_section_updated

The following is what i have right now for people to download from my site. It works with a class attribute without using the doWrap. If someone could explain how I would add the doWrap I will, however I don’t think it’s too important since it will never be used in a list. Most likely the user will just include the tag next to a link to a section. this way it will say About^updated^

<code>
function swf_section_updated($atts) {
if (is_array($atts)) extract($atts);
$offset = isset($offset) ? $offset : “1”;
$message = isset($message) ? $message : “<sup>updated</sup>”;
$section = isset($section) ? $section : “default”;
if (isset($class)) {$message = ‘<span class=”’.$class.’”>’.$message.’</span>’;};
$result = getRows(“SELECT Posted FROM “.PFX.“textpattern WHERE Section = ‘$section’ AND Status = ‘4’ AND Posted > DATE_SUB(NOW, INTERVAL $offset DAY) LIMIT 1”);

if ($result) {return $message;}; }
</code>

Offline

#7 2005-07-15 21:34:47

igner
Plugin Author
Registered: 2004-06-03
Posts: 337

Re: swf_section_updated

What you have will work just fine – alternately you could use <code>doTag()</code> rather than <code>doWrap()</code>. <code>doWrap()</code> is there more to make it easier to add wraptag support – but in your case that wouldn’t really be of benefit.

<code>
function swf_section_updated($atts) {
if (is_array($atts)) extract($atts);
$offset = isset($offset) ? $offset : “1”;
$message = isset($message) ? $message : “<sup>updated</sup>”;
$section = isset($section) ? $section : “default”;
if(isset($class)) { $tag = ‘span’;
} else { $tag = ‘sup’; $class = ‘’;
}
$result = getRows(“SELECT Posted FROM “.PFX.“textpattern WHERE Section = ‘$section’ AND Status = ‘4’ AND Posted > DATE_SUB(NOW, INTERVAL $offset DAY) LIMIT 1”);
if ($result) {return doTag($message, $tag, $class);}; }
</code>


And then my dog ate my badger, and the love was lost.

Offline

#8 2005-07-16 11:34:20

creativesplash
Member
From: Coimbatore, India
Registered: 2005-01-19
Posts: 283
Website

Re: swf_section_updated

Thanx Scott. I’ll have a go at later on tonight and let you know the results.


“Take a point, stretch it into a line, curl it into a circle, twist it into a sphere, and punch through the sphere.”

— Albert Einstein

Offline

#9 2006-06-02 22:37:01

lee
Member
From: Normandy, France
Registered: 2004-06-17
Posts: 831

Re: swf_section_updated

Nice plugin, thanks.

Offline

#10 2006-08-05 04:29:36

Xenia
New Member
Registered: 2006-01-03
Posts: 2
Website

Re: swf_section_updated

I’m getting a 404 trying to download the plugin. Please can you point me to the location of the plugin? Thank you! :-D

Offline

#11 2006-08-05 17:13:15

swf
Plugin Author
From: Saskatoon, Saskatchewan Canada
Registered: 2004-06-21
Posts: 109
Website

Re: swf_section_updated

that’s weird my .htaccess file was empty. Everything should work now

Offline

#12 2006-08-06 08:58:02

Xenia
New Member
Registered: 2006-01-03
Posts: 2
Website

Re: swf_section_updated

Thank you! I was able to download the plugin. :)

Offline

Board footer

Powered by FluxBB