I've been looking for a way to accomplish this, but as of yet am unsuccessful. Is there a way to stop allowing certain content types from being published beyond a specific date and time? I was thinking maybe a cron job I could set up, but then I wasn't sure how to get around the login issue. Any thoughts?

Comments

NewZeal’s picture

If you have a custom module for your site a simple hook_form_alter with a condition that tests the node/add/contest_content_type against a date (which could be set through admin settings), you could stop new nodes being created and supply a message such as "Contest expired..."

Passing Phase Web Development

shadow_jh’s picture

This sounds interesting... unfortunately I don't have any experience creating drupal modules.

WorldFallz’s picture

you could probably use the rules module and schedule a rule to remove create permission from the content type at a specified time.

===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz

shadow_jh’s picture

Because of the modules needed to bring the site to its current status, drupal 5 was needed - rules is or 6. Even so, I didn't see an option for content types.

WorldFallz’s picture

The rules module can definitely handle this-- you would create a custom rule with php that's run with the cron event. Unfortunately, the d5 version, which was called "workflow_ng", doesn't have the cron event iirc-- that leaves you with new zeal's suggestion.

===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz

shadow_jh’s picture

Ok, I ended up using workflow_ng - which seems to be perfect. I created some custom php :

	//Place contest browser friends name (the last part of the URL):
	$contest = "nameofcontest";

        //Place ending date of the contest in this format Year/Month(01)/Day(01)
        $exp_date = "2009-01-22"; 
        
        
        
        //DON'T EDIT below this line--------------------------------------
        $contest = "/node/add/".$contest;
        $currentpage = $_SERVER['REQUEST_URI'];
        $todays_date = date("Y-m-d"); 
        $today = strtotime($todays_date); 
        $expiration_date = strtotime($exp_date); 
        
        if ($expiration_date <= $today && $contest == $currentpage) { return true;}
        else {return false;} 

So if a user tries to add new content of that type, this code comes back true and the corresponding rule that I set up, redirects them to their other options with a message that says "sorry, this contest has ended".

Pretty cool stuff... I just wish there was a way to set up an interface for this functionality rather than having to dive into php.