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?
-
☆ 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.
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.
-
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.
Yeah, one step closer to the ideal -- still problem on the backend to make it user-selectable.