Differences

This shows you the differences between two versions of the page.

english:phpwcms_replacer_rts:frontend_render:date-last-update [2011/04/23 12:39]
Knut Heermann (flip-flop) created
english:phpwcms_replacer_rts:frontend_render:date-last-update [2018/06/03 18:09] (current)
Line 5: Line 5:
FIXME Better translate FIXME Better translate
-**RT to view the date of the last inserted/modified article or content part of the whole page.**+**RT to view the date of the last inserted/modified article or content part of the whole site.**
-In the script can be set if the articles/CPs in hidden categories should be included. \\ +In the script you can define if the articles/CPs in hidden categories should be included. \\ 
-Articles not included that are located within custom/protected categories.+Articles located within custom/protected categories won't be included.
-The output can be customized according to the usual php-date rules. E.g. {DATE_UPDATE:d.m.Y H:m} liefert 01.02.2010 12:23 \\ +The output can be customized according to the usual php-date rules. E.g. {DATE_UPDATE:d.m.Y H:i} delivers 01.02.2010 12:23 \\
or in the script is changed to set the format as in "conf.template.default.inc.php". The TAG for this: {DATE_UPDATE}. \\ or in the script is changed to set the format as in "conf.template.default.inc.php". The TAG for this: {DATE_UPDATE}. \\
//(At the end of the script, uncomment the line)//. //(At the end of the script, uncomment the line)//.
Line 29: Line 29:
**Version:** V1.0 \\ **Version:** V1.0 \\
- +**Update 25.04.2011:**  
 +This eliminates the possibility to read other columns from the article field e.g. the ID of the article.
-TAG: **{DATE_UPDATE}** oder z.B. **{DATE_UPDATE:d.m.Y H:m}** \\+  * Correction for databases that support no subqueries in the SELECT statement. //(This eliminates the possibility to read other columns from the article field e.g. the ID of the article. For our purposes, this is unimportant).// 
 +  * Correction: Special case when articles/CPs were created/edited in "Home" id = 0. 
 + 
 +TAG: **{DATE_UPDATE}** oor e.g. **{DATE_UPDATE:d.m.Y H:i}** \\
Filename: **rt_date_last_update.php** Filename: **rt_date_last_update.php**
Line 83: Line 87:
 * The most recent Article date of the entire page (Article and CP)  * The most recent Article date of the entire page (Article and CP)
 * 2011/04/22 V1.0  Knut Heermann (flip-flop) http://planmatrix.de  * 2011/04/22 V1.0  Knut Heermann (flip-flop) http://planmatrix.de
 + * Update 2011/04/22 V1.0: MySQL Engines that also support subqueries in SELECT statement
 + *                         Special case article in "home"
 *  *
 * Settings: @show_hidden: [0|1|2]  * Settings: @show_hidden: [0|1|2]
Line 90: Line 96:
 *  - [2] all categories  *  - [2] all categories
 *    *  
- * TAG:    E.g. {DATE_UPDATE:d.m.Y H:m} or optional {DATE_UPDATE}+ * TAG:    E.g. {DATE_UPDATE:d.m.Y H:i} or optional {DATE_UPDATE}
 *  *
 * Output: Optional settings from "conf.template.default.inc.php". Have a look to  * Output: Optional settings from "conf.template.default.inc.php". Have a look to
Line 114: Line 120:
// -------------------------------------------- // --------------------------------------------
- $sql  = "SELECT article_id, UNIX_TIMESTAMP(max(article_tstamp)) AS max_article_tstamp, ";+ $result = array(); 
 +  
 + $sql  = "SELECT UNIX_TIMESTAMP(max(article_tstamp)) AS max_article_tstamp "; 
 + // Nur fuer MySQL Engines geeignet die auch im SELECT Unterabfragen unterstuetzen  
 + // Only suitable for MySQL Engines that also support subqueries in SELECT statement 
 +/* 
 + $sql .= ",article_id, ";
$sql .= "article_begin AS article_livedate, "; $sql .= "article_begin AS article_livedate, ";
$sql .= "article_end AS article_killdate "; $sql .= "article_end AS article_killdate ";
 +*/
$sql .= "FROM ".DB_PREPEND."phpwcms_article ar LEFT JOIN ".DB_PREPEND."phpwcms_articlecat ac ON "; $sql .= "FROM ".DB_PREPEND."phpwcms_article ar LEFT JOIN ".DB_PREPEND."phpwcms_articlecat ac ON ";
$sql .= "ar.article_cid = ac.acat_id WHERE "; $sql .= "ar.article_cid = ac.acat_id WHERE ";
 +
// Categorie settings ------------- // Categorie settings -------------
$sql .= "ac.acat_aktiv=1 AND ac.acat_public=1 AND ac.acat_trash=0 AND "; $sql .= "ac.acat_aktiv=1 AND ac.acat_public=1 AND ac.acat_trash=0 AND ";
Line 137: Line 151:
// Article settings // Article settings
$sql .= "ar.article_deleted=0 AND ar.article_begin<NOW() "; $sql .= "ar.article_deleted=0 AND ar.article_begin<NOW() ";
- $sql .= "AND IF(ac.acat_archive=1 AND ar.article_archive_status=1, 1, ar.article_end>NOW()) LIMIT 1";+ $sql .= "AND IF(ac.acat_archive=1 AND ar.article_archive_status=1, 1, ar.article_end>NOW()) LIMIT 1 ";
$result = _dbQuery($sql); $result = _dbQuery($sql);
- $my_date = (isset($result['0']['max_article_tstamp'])) ? $result['0']['max_article_tstamp']: '--';+  
 + // ------------------ Special case article in "home" 
 + // Category settings in: $content["struct"]['0'] 
 +  
 + // catch the articles in "home" ID =
 + $sql  = "SELECT UNIX_TIMESTAMP(max(article_tstamp)) AS max_article_tstamp "; 
 + $sql .= "FROM ".DB_PREPEND."phpwcms_article WHERE "; 
 + $sql .= "article_cid=0 AND "; 
 + $sql .= "article_public=1 AND article_aktiv=1 AND "; 
 + $sql .= "article_deleted=0 AND article_begin<NOW() AND "; 
 + // Category settings from "home" 
 + if ($content["struct"]['0']['acat_permit']['acat_archive'] == 1) 
 + $sql .= "IF(article_archive_status=1, 1, article_end>NOW()) "; 
 + else  
 + $sql .= "article_end>NOW() "; 
 + $sql .= "LIMIT 1 "; 
 +  
 + $result0 = _dbQuery($sql); 
 +  
 + // Article in "Home" the youngest one? 
 + if (isset($result0['0']['max_article_tstamp']) AND ($result0['0']['max_article_tstamp'] > $result['0']['max_article_tstamp']) ) 
 + $result['0']['max_article_tstamp'] = $result0['0']['max_article_tstamp']; 
 + // ------------------ 
 +  
 + $my_date = (isset($result['0']['max_article_tstamp'])) ? $result['0']['max_article_tstamp']: time();
Line 149: Line 187:
// $template_default["date"]["long"/medium/short] // $template_default["date"]["long"/medium/short]
// ------------------------------------------------ // ------------------------------------------------
-// $content["all"] = str_replace('{DATE_UPDATE}', international_date_format($template_default["date"]["language"], $template_default["date"]["long"],   $my_date),   $content["all"]);+// $content["all"] = str_replace('{DATE_UPDATE}', international_date_format($template_default["date"]["language"], $template_default["date"]["long"],  $my_date),   $content["all"]);
// $content["all"] = str_replace('{DATE_UPDATE}', international_date_format($template_default["date"]["language"], $template_default["date"]["medium"], $my_date),   $content["all"]); // $content["all"] = str_replace('{DATE_UPDATE}', international_date_format($template_default["date"]["language"], $template_default["date"]["medium"], $my_date),   $content["all"]);
// $content["all"] = str_replace('{DATE_UPDATE}', international_date_format($template_default["date"]["language"], $template_default["date"]["short"],  $my_date),   $content["all"]); // $content["all"] = str_replace('{DATE_UPDATE}', international_date_format($template_default["date"]["language"], $template_default["date"]["short"],  $my_date),   $content["all"]);
-// $content["all"] = str_replace('{DATE_UPDATE}', international_date_format($template_default["date"]["language"], 'd.m.Y H:m',                         $my_date),   $content["all"]);+// $content["all"] = str_replace('{DATE_UPDATE}', international_date_format($template_default["date"]["language"], 'd.m.Y H:i',                        $my_date),   $content["all"]);
$content["all"] = render_date($content["all"], $my_date, 'DATE_UPDATE'); $content["all"] = render_date($content["all"], $my_date, 'DATE_UPDATE');
english/phpwcms_replacer_rts/frontend_render/date-last-update.1303555197.txt.gz · Last modified: 2018/06/03 18:08 (external edit)
www.planmatrix.de www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0