Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-10-25 15:15:46

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

automaticly deleting (expired) articles

hey all,

i am searching for a solution to automatically delete (not archive) articles on a given expiration date and time, which can be the same as the article’s posting date.

does anyone happen to know how to do that?


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

Offline

#2 2006-10-26 02:16:57

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

Re: automaticly deleting (expired) articles

A plugin or cron script would be needed.

Offline

#3 2006-10-26 03:27:34

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

Re: automaticly deleting (expired) articles

a plugin. i started researchign that already, but basically i needed a global overview about the txp functions and in which file to find them…
mary?


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

Offline

#4 2006-10-26 03:47:31

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

Re: automaticly deleting (expired) articles

Well, the database-related functions you need can be found in textpattern/lib/txplib_db.php.

To do it with a plugin, what you’ll need to do is make a function that does the actual deleting (running the necessary query), then have it run wherever needed with the necessary callbacks.

Now, I think you’ll want it run for the event “pretext” – that will get rid of them before fetching any articles from the front-end (site, feeds, etc). Then you need to decide if you want them scrapped when you use the admin-side (if so, add those callbacks), or if you’re okay with them remaining there until someone tries to request them from the front-end.

If you make use of the sending last modified headers feature, you should update that when you delete, as well (just run update_lastmod();, no parameters).

Offline

#5 2006-10-26 19:16:34

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

Re: automaticly deleting (expired) articles

thank you very much, mary, your explanation is almost a detailed manual to do the plug, it seems!

now to me it seems necessary to store a expiration date with every article.
how could that be achieved?
it is probably possible to turn one of the custom fields into a date (incl. hour) field i guess, i somehow have a clue how this might work (have to fiddle) – but could/would you think of another way to achieve this?

on another note it seems necessary to limit the function to run in specified intervals rather than when a user visits. the plugin could potentially used on a large site full of entries, that expire due to their nature of being, say, an auction entry or classifieds or or or.
since these sites sometime shave many many visitors it’ll be necessary to hinder the function to run on every visit, it seems.

tooot!

Last edited by jayrope (2006-10-26 19:27:12)


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

Offline

#6 2006-10-27 03:05:47

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

Re: automaticly deleting (expired) articles

…it seems necessary to limit the function to run in specified intervals rather than when a user visits.

The only way to do that is with a CRON script; you make a PHP script and have CRON execute it. If you’ve got a half-decent webhost, you should have it available to you from whatever control panel your host has provided you with. The cron command to run would look like:

/usr/bin/php /path/to/your/script.php

If you don’t have CRON, a plugin run when a user visits is the only other way to achieve similar effects.

As far as dates, you could do it with a custom field and use strtotime to convert the user entered datetime into a timestamp to do the time math with.

Offline

#7 2006-10-30 17:35:40

rtxpn
Member
Registered: 2006-06-19
Posts: 11
Website

Re: automaticly deleting (expired) articles

There’s a plug-in that was just released that does this (I need the same thing). I’ve tried to post a follow-up on that plug-in’s page but I’m having ‘issues’ doing so.

Here’s the information for that plug-in and a link to a thread I started about it:

msv_if_custom_article_date Forum Thread

msv_if_custom_article_date

Martin Švihla’s Textpattern plugins

Offline

#8 2006-10-30 18:20:07

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

Re: automaticly deleting (expired) articles

hey rtxpn, thanx for posting.

unfortunately the author’s website does not mention a deletion of articles at all. as far as i understood the plugin it allows separation of articles by date, but it does not supply any code, which would delete expired articles from the database.
i believe this would need articles to be able to store an individual expiration date


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

Offline

#9 2006-11-03 06:39:37

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

Re: automaticly deleting (expired) articles

Hey jayrope, give this a try and tell me what you think.

Plugin Link ras_delete_expired_v4.0.4.4.txt
Info Link Updated example

I tried the article form tag approach and didn’t like a lot of what it would take to keep it from getting messy, a bit out of my league I think. The admin side was much easier to work with and came out pretty well, it’s untested and deletes article content but I haven’t seen any problems with it yet. I wouldn’t use it on a production just yet though.
The plugin allows for prudent positive controls and well organized automation, strikes me as something that might make a great feature request with some controls added for access privs.

Last edited by rsilletti (2006-11-14 00:54:24)

Offline

#10 2006-11-05 18:38:25

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

Re: automaticly deleting (expired) articles

rick,

!!!

wonderful. i will try it, but have to set up a test site first. ouch. will do so now.
man it thrills, that you did it already! (probably at least, lemme test.,..)


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

Offline

#11 2006-11-05 19:15:00

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

Re: automaticly deleting (expired) articles

rick – works like a charm over here on a fresh install of 4.0.4.

do you think it’ll be possible to take care of the deletion in a more automated fashion?
given, that one runs a site with classifieds, it’ll make sense to have all expired classifieds being deleted automatically, when admin logs onto the backend of the site for instance.

apart from that: monsieur: my deepest compliments for this.
edit: i’ll send you a selection of programming friendly music of mine for making the work easier anytime…

janek

Last edited by jayrope (2006-11-05 19:16:08)


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

Offline

#12 2006-11-05 20:44:23

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

Re: automaticly deleting (expired) articles

You are more than welcome, thanks for suggesting it. The next step would be a preference setting for automating the process, I’m already tweeking at it. :)

Offline

Board footer

Powered by FluxBB