Filter Your Published and Unpublished Content For Deletion

Register an Account
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 12-05-2007, 08:15 PM
Pligg Donor
Pligg Version: 9.9.5
 
Join Date: Sep 2007
Posts: 192
Hi All!

I searched around the forum for a good solution towards deleting published and unpublished content from my pligg site after X amount of days. My site relies on content to be removed after 30 days or so, so you can imagine that it's quite a pain to sift through 100's of stories. I then found this link to be quite helpful. The only problem was, I still had to sift though each story to see which one was older than 30 days -- in which case, I had to again use phpMyadmin and do it the hard way. I also found another solution on here that supposedly removed stories automatically with a cron job -- but that solution was written quite some ago and it didn't work for me on v 9.8.2. So anyway, I came up with my own solution of filtering out the content items, so I could then use the helpful mod I mentioned above. So install that mod first then add this feature.

This should make things easier for folks like me who wish to delete their content items after a certain amount of days. You will still have to discard/delete them manually, but at least it should be easier to find them now.

Please note: This is for v 9.8.2. It should work for other previous versions as well, but use at your own risk. Make a backup just in case.

Open admin_links_center.tpl and find this:

Code:
<form action="{$my_pligg_base}/admin_links.php" method="get">
	<select name="filter">
		<option value="all" {if $templatelite.get.filter eq "all"} selected="selected" {/if}>All</option>
		<option value="published" {if $templatelite.get.filter eq "published"} selected="selected" {/if}>Published</option>
		<option value="upcoming" {if $templatelite.get.filter eq "upcoming"} selected="selected" {/if}>Queued</option>
		<option value="discard" {if $templatelite.get.filter eq "discard"} selected="selected" {/if}>Discard</option>
		<option>   ---   </option>
		<option value="today" {if $templatelite.get.filter eq "today"} selected="selected" {/if}>Today</option>
		<option value="yesterday" {if $templatelite.get.filter eq "yesterday"} selected="selected" {/if}>Yesterday</option>
		<option value="week" {if $templatelite.get.filter eq "week"} selected="selected" {/if}>This Week</option>
	</select>
	<input type="submit" value="Filter" class="log2">
</form>
Replace with this:

Code:
<form action="{$my_pligg_base}/admin_links.php" method="get">
	<select name="filter">
		<option value="all" {if $templatelite.get.filter eq "all"} selected="selected" {/if}>All</option>
		<option value="published" {if $templatelite.get.filter eq "published"} selected="selected" {/if}>Published</option>
		<option value="upcoming" {if $templatelite.get.filter eq "upcoming"} selected="selected" {/if}>Queued</option>
		<option value="discard" {if $templatelite.get.filter eq "discard"} selected="selected" {/if}>Discard</option>
                <option value="expired" {if $templatelite.get.filter eq "expired"} selected="selected" {/if}>Expired</option>
		<option>   ---   </option>
		<option value="today" {if $templatelite.get.filter eq "today"} selected="selected" {/if}>Today</option>
		<option value="yesterday" {if $templatelite.get.filter eq "yesterday"} selected="selected" {/if}>Yesterday</option>
		<option value="week" {if $templatelite.get.filter eq "week"} selected="selected" {/if}>This Week</option>
	</select>
	<input type="submit" value="Filter" class="log2">
</form>
Now open admin_links.php and find this:

Code:
case 'week':
	$wknum =  date('w', strtotime("now"));
if ($wknum > 0) {
	$tsdt = date('Ymd000000', strtotime("-{$wknum} day"));
	$fsdt = date('Ymd235959', strtotime("now"));
	} else {
	$tsdt = date('Ymd000000', strtotime("now"));
	$fsdt = date('Ymd235959', strtotime("now"));
	}
	$filtered = $db->get_results("SELECT link_id FROM " . table_links . " WHERE (link_date >= $tsdt AND link_date <= $fsdt) ORDER BY link_date DESC LIMIT $offset,25");
	$rows = $db->get_var("SELECT count(*) FROM " . table_links . " WHERE (link_date >= $tsdt AND link_date <= $fsdt)");						
	break;
Replace with this:

Code:
case 'week':
	$wknum =  date('w', strtotime("now"));
if ($wknum > 0) {
	$tsdt = date('Ymd000000', strtotime("-{$wknum} day"));
	$fsdt = date('Ymd235959', strtotime("now"));
	} else {
	$tsdt = date('Ymd000000', strtotime("now"));
	$fsdt = date('Ymd235959', strtotime("now"));
	}
	$filtered = $db->get_results("SELECT link_id FROM " . table_links . " WHERE (link_date >= $tsdt AND link_date <= $fsdt) ORDER BY link_date DESC LIMIT $offset,25");
	$rows = $db->get_var("SELECT count(*) FROM " . table_links . " WHERE (link_date >= $tsdt AND link_date <= $fsdt)");						
	break;
case 'expired':
	$tsdt = date('Ymd000000', strtotime("-99999 day"));
	$fsdt = date('Ymd235959', strtotime("-31 day"));
	$filtered = $db->get_results("SELECT link_id FROM " . table_links . " WHERE (link_date >= $tsdt AND link_date <= $fsdt) ORDER BY link_date DESC LIMIT $offset,250");
	$rows = $db->get_var("SELECT count(*) FROM " . table_links . " WHERE (link_date >= $tsdt AND link_date <= $fsdt)");						
	break;
That's all. You should now be able to filter your results from the back end under the news management section by selecting Expired. Only the content that is X amount of days or older will be filtered, thereby allowing you to change their status to Discard and deleting them altogether. You can set the parameters (in the above code in red color) to however many days you want the filter to work as. It is currently set to filter out stories for 31 days old or more -- but change it to however you like. I also set the default display for 250 rows, because a site like mine has many stories to be deleted at once, and it's a pain to keep doing 25 entries at a time for me. I'd rather just do 250 per time. You can change this parameter to whatever you want as well (highlighted in blue).

I hope this makes things smoother for some of you who ran into the same problem as I have. It would great if someone could develop a way to set an automatic lifespan for the content and a cron job to delete "expired" stories altogether -- but until this method exists (that actually works), this should help you out for now as it did me.

Last edited by blaze; 12-05-2007 at 08:31 PM.
Reply With Quote
  #2 (permalink)  
Old 12-05-2007, 08:49 PM
Yankidank's Avatar
Pligg Founder/Coder/Designer
Pligg Version: SVN
Pligg Template: Wistie
 
Join Date: Dec 2005
Location: Ocala, FL
Posts: 4,934
Send a message via AIM to Yankidank
Thanks for this. I understand why you would want to discard unpublished stories, but why don't you keep archives for old published stories? I would think that would hurt with SEO.

The Twitter Module for Pligg CMS!
Register, Login, and Submit Stories with Twitter. An absolute MUST HAVE for all Pligg sites!
Reply With Quote
  #3 (permalink)  
Old 12-05-2007, 10:49 PM
Pligg Donor
Pligg Version: 9.9.5
 
Join Date: Sep 2007
Posts: 192
Quote:
Originally Posted by Yankidank View Post
Thanks for this. I understand why you would want to discard unpublished stories, but why don't you keep archives for old published stories? I would think that would hurt with SEO.
This all depends on what type of content you are delivering. For example, let's say you run a deal site. Archiving these deals wouldn't make sense because the deals expire anyway. As for SEO, I'd rather design the site and maintain it FOR PEOPLE, not for search engines. It's a known fact that if you do this, you will win out in the long run.

Besides, there has been a lot of talk about Google favoring smaller boutique sites that design their sites for people rather than for google -- as a result, it's not as hard now to knock off the larger database sites nowadays for the top spots. Whether or not this is true is debatable -- I will say though, from my experience, it seems to be going in that direction. I just pulled the number one spot in google for my keyword phrase (very competitive), and it took me only a year to do it. Everyone told me there was no way it could be done because the "other" sites were sitting up there on top for nearly 10 years.

Anyway, that's why I needed to delete my content. My database fills up very fast and every story has an image. This stuff needs to be deleted every 30 days. It's no fun for people to sift through 1000's of stories -- nor is it fun for me to delete them one at a time. :P
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Published + unpublished stories SQL zeinster Questions and Comments 2 05-31-2008 05:57 PM
How to make unpublished story a published one sanvera Questions and Comments 2 04-23-2007 05:40 PM
Another status besides Published, Unpublished atulbansal Questions and Comments 5 03-26-2007 02:11 PM
Turn all unpublished into published auto?(bypass) Martyn Questions and Comments 1 01-27-2007 10:44 PM
published vs. unpublished kailio Questions and Comments 6 01-15-2007 04:16 PM


Pligg Modules and Pligg Templates from Pligg Pro Find support on the Pligg CMS Forum - 24 hours a day! Make a donation to support Pligg CMS development