We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31471
    • 206 Posts
    How, when and where ’pub_date’ & ’unpub_date’ properties are processed?
    If I wand to set unpub_date as a sorting key, will I see those documents unpublished after their unpub_date?
    Where are they processed in the core?
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      It’s part of the checkPublishStatus function in document.parser.class.inc (the parser); about line 533:
                  $sql= "UPDATE " . $this->getFullTableName("site_content") . " SET published=0, publishedon=0 WHERE " . $this->getFullTableName("site_content") . ".unpub_date <= $timeNow AND " . $this->getFullTableName("site_content") . ".unpub_date!=0 AND published=1";
      

      The function is called around line 1072 of the parser, in the main executeParser function. It is processed immediately after the site’s status (site available/unavailable) is determined and immediately before the document to be generated is determined. It uses the assets/cache/sitePublishing.idx.php file to determine if any documents need to be published or unpublished.
        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
        • 31471
        • 206 Posts
        Thanks, Susan! This means it was not a big idea to sort on the unpub_date! smiley
          • 31471
          • 206 Posts
          For anyone who ever considered writing date for sorting purpose in a standard document-propertiy, I recommend menuindex. Holding a timestamp it still can be handled in its original manner too.
          In the database, it is stored as INT(10) -- pub_date and unpub_date are INT(20) -- but it is yet enough for the timestamp.
          Thou it is a problem to serve a datepicker for the menuindex in the manager.
            • 22303 MODX Staff
            • 10,725 Posts
            I think the publishedon field is the timestamp you want to sort on. That or createdon, depending on your needs.
              • 31471
              • 206 Posts
              Yeah, one step closer to the ideal -- still problem on the backend to make it user-selectable.
                • 22303 MODX Staff
                • 10,725 Posts
                Quote from: vhollo at May 26, 2009, 06:09 PM

                Yeah, one step closer to the ideal -- still problem on the backend to make it user-selectable.
                That should be a feature request for Evo IMO. Revo already provides this.