Quote from: sottwell at Jun 07, 2009, 11:53 PM
I’m a bit confused as to exactly why you would want to do this. Can’t your editor just use the regular unpublish field when editing the document?
Some of my clients have a hard time finding the pub date otpions since they are in the second tab. Can ManagerManager be used to move these fields to the main tab? that may be a solution.
As for it not working...It seems that $_POST[’tvevent_time’] has the time selector format and has not been converted to timestamp yet. Add a strtotime to the code and it will work. This worked on my test server. You may want to avoid the query if the tv date is already the same as the unpub date.
//<?php
$e = &$modx->Event;
switch ($e->name) {
case "OnDocFormSave":
$unpub_date = strtotime($_POST['tveventdate']);
$table = $modx->getFullTableName( 'site_content' );
$fields = array('unpub_date' => $unpub_date);
$modx->db->update( $fields, $table, 'id = "'.$id.'"' );
break;
default :
return; // stop here - this is very important.
break;
}
EDIT: to set it to +1 day automatically add the +1 day parameter to the strtotime....
$unpub_date = strtotime('+1 day', $_POST['tveventdate']);