We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27708 MODX Staff
    • 2,502 Posts
    I tried adding it as follows:

    function InsertUnPubDate($data) {
    	global $modx;
    	$table_name = $modx->getFullTableName( 'site_content' );
    	$fields = $data['unpub_date']);
    	$modx->db->insert( $fields, $table_name);
    }
    $arr = $modx->getTemplateVarOutput('event_date');
    $aday = 84600;
    $edate = $arr[event_date];
    $data = $edate + $aday;
    $_POST['unpub_date'] = $data;
    if (!isset($edate))
    {exit();}
    else {InsertUnPubDate($_POST['unpub_date'];}
    


    but nothing. sad

    Hrmm...
      Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
      • 27708 MODX Staff
      • 2,502 Posts
      Susan, I am assuming since you retracted the info re the document array that you don’t think that it will actually work. I did try it but I also found an error in my code and after fixing it it wasn’t working still.

      The last post is where I last left off.
        Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        somehow I got turned around and thought this was a regular Manager document editing process... shouldn’t answer forum issues when I have a bad cold! Sorry for the confusion...
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 7231
          • 4,205 Posts
          I think that there is an extra ) in this line:

          $fields = $data['unpub_date']);


          and missing a ) in this line:

          else {InsertUnPubDate($_POST['unpub_date'];}
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don't know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 8960
            • 150 Posts
            Was this ever resolved? I need the same thing, only 2 weeks after a post has been made. Did the snippet SmashingRed wrote work? Guess I’ll have to try it myself.
              • 27708 MODX Staff
              • 2,502 Posts
              I didn’t get this resolved wholly since there was a problem with saving the data. It never ended being critical to the project. I decided to move on. ER if you decide to move ahead, please let us know your progress here.

              Cheers,

              Jay
                Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
                • 4172
                • 5,888 Posts

                I use my Xett to manage events. Here is the function where I store the edited event. In this case I use the docmanager

                <?php
                require_once($Xettpath.'document.class.inc.php');
                
                $createdby=$modx->getLoginUserID();
                $rows = $this->getformfields();
                $time=time();
                $parent=$this->xetconfig['custom']['zeiten_parent'];
                $template=$this->xetconfig['custom']['zeiten_template'];
                $unpubtime=$this->xetconfig['custom']['unpublish_days']*86400;
                
                
                if ($_POST['aktion']=='edit'){
                
                //print_r($rows);
                foreach ($rows as $row){
                $start=xetadodb_strftime("%d-%m-%Y %H:%M:%S", $row['`Time`']);
                $unpub=$row['`Time`']+$unpubtime;
                $doc = new Document($row['`docid`']);
                $doc->Set('parent',$parent);
                //$doc->Set('content',$row['`content`']);
                $doc->Set('description',$row['`description`']);
                $doc->Set('template',$template);
                $doc->Set('pagetitle','Sendezeit '.$start);
                $doc->Set('longtitle','Sendezeit '.$start);
                $doc->Set('menutitle','Sendezeit '.$start);
                $doc->Set('cacheable','0');
                $doc->Set('hidemenu','1');
                $doc->Set('published',$row['`published`']);
                $doc->Set('isfolder','0');
                $doc->Set('unpub_date',$unpub);
                $doc->Set('editedby',$createdby);
                //$doc->Set('createdon',$time);
                $doc->Set('editedon',$time);
                //$doc->Set('publishedon',$createdby);
                $doc->Set('tvmoderator',$row['`moderatorId`']);
                $doc->Set('tvsendungstyp',$row['`category_ID`']);
                $doc->Set('tvEasyEvents_Start',xetadodb_strftime("%d-%m-%Y %H:%M:%S", $row['`Time`']));
                $doc->Set('tvEasyEvents_End',xetadodb_strftime("%d-%m-%Y %H:%M:%S", $row['`Timeend`']));
                $doc->Save();
                $parent = $doc->fields['id'];
                //$output.='$docids'."['vcal_eventcal']='".$parent."';<br/>";	
                }
                
                }
                ?>
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 10449
                  • 956 Posts
                  It depends a bit how you actually store the event dates. Personally, I prefer the mysql DATETIME format (i.e. YYYY-MM-DD hh:mm), hence I save the values like that when using such TVs.

                  Here’s such a snippet (tested with 0.9.6.3 RC2):

                  <?php
                  
                  $eventTV = 'eventDate'; // TV name where we store the event dates
                  $debug = true; // show or hide vars on screen
                  
                  $pre = $modx->db->config['table_prefix'];
                  
                  // table names:
                  $tvDefTable = $pre . 'site_tmplvars'; // tv definitions (id - name)
                  $tvValTable = $pre . 'site_tmplvar_contentvalues'; // tv values
                  $contentTable = $pre . 'site_content'; // site content
                  
                  
                  // get TV id:
                  $dbQuery = "SELECT id as tvid FROM $tvDefTable WHERE name='$eventTV'";
                  $result = mysql_query($dbQuery) or die( mysql_error() );
                  while ($row = mysql_fetch_array($result)) {
                  	extract($row);
                  }
                  
                  
                  // get all documents using this TV:
                  $dbQuery = "SELECT contentid as cid, value as eventDate, UNIX_TIMESTAMP(value) as unixDate, DATE_ADD(value, INTERVAL 1 DAY) as unpubDate FROM $tvValTable WHERE tmplvarid='$tvid'";
                  $result = mysql_query($dbQuery) or die( mysql_error() );
                  while ($row = mysql_fetch_array($result)) {
                  
                  	extract($row);
                  
                  	$eventDocs[$cid]["raw"] = $eventDate; // value as is from TV-value (format: YYYY-MM-DD hh:mm)
                  	$eventDocs[$cid]["unix"] = $unixDate; // value as Unix timestamp (integer)
                  	$eventDocs[$cid]["unpub"] = $unpubDate; // unpublish date, TV value + 1 day
                  
                  	$intID = (int) $cid;
                  	$url = $modx->makeUrl($intID, '', '', 'full');
                  	$eventDocs[$cid]["url"] = $url; // event details URL
                  
                  }
                  
                  
                  // just for debugging: show array on screen
                  if($debug) {
                  	echo '<pre>';
                  	print_r($eventDocs);
                  	echo '</pre>';
                  }
                  
                  
                  
                  // update unpub dates:
                  foreach($eventDocs as $k=>$v) {
                  	$docid = (int) $k;
                  	$unpubDateTime = $eventDocs[$k]["unpub"];
                  	$dbQuery = "UPDATE $contentTable SET unpub_date=UNIX_TIMESTAMP('$unpubDateTime') WHERE id=$docid";
                  	$result = mysql_query($dbQuery) or die( mysql_error() );
                  }
                  
                  ?>
                  


                  YMMV...