NAVIGATION
This shows you the differences between two versions of the page.
deutsch:ersetzer_rts:frontend_render:datum-letztes-update [2011/04/22 23:20] Knut Heermann (flip-flop) |
deutsch:ersetzer_rts:frontend_render:datum-letztes-update [2020/03/23 11:05] (current) Uwe Tholey |
||
---|---|---|---|
Line 8: | Line 8: | ||
Artikel die innerhalb benutzerspezifischen/geschützten Kategorien liegen werden nicht berücksichtigt. | Artikel die innerhalb benutzerspezifischen/geschützten Kategorien liegen werden nicht berücksichtigt. | ||
- | Die Ausgabe kann nach den üblichen php-Datumregeln gestaltet werden. Z.B. {DATE_UPDATE:d.m.Y H:m} liefert 01.02.2010 12:23 \\ | + | Die Ausgabe kann nach den üblichen php-Datumregeln gestaltet werden. Z.B. {DATE_UPDATE:d.m.Y H:i} liefert 01.02.2010 12:23 \\ |
oder im Script wird auf die Formatierung wie in conf.template.default.inc.php vorgegeben umgeschaltet. Der TAG dazu: {DATE_UPDATE}. \\ | oder im Script wird auf die Formatierung wie in conf.template.default.inc.php vorgegeben umgeschaltet. Der TAG dazu: {DATE_UPDATE}. \\ | ||
//(Am Ende des Scripts die Zeilen entkommentieren)//. | //(Am Ende des Scripts die Zeilen entkommentieren)//. | ||
+ | |||
+ | Ähnliche Funktion siehe: [[deutsch/ersetzer_rts/frontend_render/newx]] | ||
\\ | \\ | ||
Line 25: | Line 27: | ||
**Version:** V1.0 \\ | **Version:** V1.0 \\ | ||
- | + | **Update 25.04.2011:** | |
+ | * Korrektur für Datenbanken die im SELECT keine Unterabfragen unterstützen. //(Dadurch entfällt die Möglichkeit auch andere Spalten aus der Artikeltabelle auszulesen z.B. die ID des betreffenden Artikels. Für unseren Anwendungsfall ist dies jedoch unwichtig).// | ||
+ | * Korrektur: Spezialfall wenn Artikel/CPs in "Home" ID=0 angelegt/editiert wurden. | ||
- | TAG: **{DATE_UPDATE}** oder z.B. **{DATE_UPDATE:d.m.Y H:m}** \\ | + | TAG: **{DATE_UPDATE}** oder z.B. **{DATE_UPDATE:d.m.Y H:i}** \\ |
Dateiname: **rt_date_last_update.php** | Dateiname: **rt_date_last_update.php** | ||
Line 35: | Line 39: | ||
**Bedingung:** -> [[http://www.phpwcms-docu.de/config_dateien.phtml|/config/phpwcms/conf.inc.php]] \\ | **Bedingung:** -> [[http://www.phpwcms-docu.de/config_dateien.phtml|/config/phpwcms/conf.inc.php]] \\ | ||
- | * ##$phpwcms['allow_ext_render'] = 1;## | + | * ##$phpwcms['allow_ext_render'] = 1;## \\ |
Line 57: | Line 61: | ||
Eine dieser Zeilen kann entkommentiert werden um **{DATE_UPDATE}** zu aktivieren. \\ | Eine dieser Zeilen kann entkommentiert werden um **{DATE_UPDATE}** zu aktivieren. \\ | ||
- | Die Ausgabeeinstellungen des Datums beziehen sich in diesem Fall auf die Variablen in der Datei "config/phpwcms/conf.template.default.inc.php". | + | Die Ausgabeeinstellungen des Datums beziehen sich in diesem Fall auf die Variablen in der Datei \\ |
+ | "config/phpwcms/conf.template.default.inc.php". | ||
* $template_default['date']['long'] | * $template_default['date']['long'] | ||
Line 78: | Line 83: | ||
* 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 85: | Line 92: | ||
* - [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 109: | Line 116: | ||
// -------------------------------------------- | // -------------------------------------------- | ||
- | $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 132: | Line 147: | ||
// 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 =0 | ||
+ | $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 144: | Line 183: | ||
// $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'); | ||
Line 157: | Line 196: | ||
\\ | \\ | ||
+ | |||
+ | ====== Datum Letztes Update Artikel & CP V 2.0===== | ||
+ | **rt_date_last_update** V2.0 22.05.2018\\ | ||
+ | Forum: [[https://forum.phpwcms.org/viewtopic.php?p=148787#p148787]]\\ | ||
+ | Autor: Oliver Georgi (phpwcms developer)\\ | ||
+ | TAG: **{DATE_UPDATE:d.m.Y H:i}** oder ohne Angabe der Uhrzeit **{DATE_UPDATE:d.m.Y}** \\ | ||
+ | Dateiname: **last_update.php**\\ | ||
+ | Verzeichnis: ** template/inc_script/frontend_render/ **\\ | ||
+ | phpwcms Version: ab 1.9 (PHP 7)\\ | ||
+ | Bedingung: -> [[http://www.phpwcms-docu.de/config_dateien.phtml|include/config/phpwcms/conf.inc.php]] \\ | ||
+ | |||
+ | * ##$phpwcms['allow_ext_render'] = 1;## \\ | ||
+ | |||
+ | |||
+ | \\ | ||
+ | |||
+ | ===== Beschreibung und Verwendung: ===== | ||
+ | - Script in das Verzeichnis template/inc_script/frontend_render/ kopieren \\ | ||
+ | - TAG **{DATE_UPDATE:d.m.Y H:i}** bzw. **{DATE_UPDATE:d.m.Y}** an der gewünschten Stelle im Template, wo die Ausgabe erfolgen soll, platzieren.\\ | ||
+ | \\ | ||
+ | :!: Im Script kann nicht mehr eingestellt werden wie die Ausgabe erfolgen soll. Es wird das Datum der letzten Aktualisierung ausgegeben, unabhängig davon ob Inhalte öffentlich oder nicht öffentlich sind.\\ | ||
+ | :!: In lokalen Serverumgebungen, z.B. xampp unter Windows, ist es möglich daß die Ausgabe fehlerhaft ist. Siehe hierzu im Forum [[https://forum.phpwcms.org/viewtopic.php?p=148794#p148794]] | ||
+ | \\ | ||
+ | |||
+ | ===== Script: ===== | ||
+ | |||
+ | Dateiname: last_update.php \\ | ||
+ | Verzeichnis: template/inc_script/frontend_render/ | ||
+ | <code php |h last_update |h > | ||
+ | <?php | ||
+ | // ------------------------------------------------------------------------------------------- | ||
+ | // ------------- Move this Script into template/inc_script/frontend_render ------------------- | ||
+ | // --------------- Use {DATE_UPDATE:d.m.Y H:i} as RT in your Template. ----------------------- | ||
+ | // ------------------------------------------------------------------------------------------- | ||
+ | // obligate check for phpwcms constants | ||
+ | if (!defined('PHPWCMS_ROOT')) {die("You Cannot Access This Script Directly, Have a Nice Day.");} | ||
+ | // ------------------------------------------------------------------------------------------- | ||
+ | if( ! (strpos($content["all"],'{DATE_UPDATE')===false)) { | ||
+ | |||
+ | $sql = 'SELECT UNIX_TIMESTAMP(latest_ts) AS latest_ts FROM(( | ||
+ | SELECT MAX(article_tstamp) AS latest_ts FROM '.DB_PREPEND.'phpwcms_article WHERE article_deleted=0 AND article_public=1 LIMIT 1) | ||
+ | UNION | ||
+ | (SELECT MAX(acat_tstamp) AS latest_ts FROM '.DB_PREPEND.'phpwcms_articlecat WHERE acat_trash=0 AND acat_aktiv=1 LIMIT 1) | ||
+ | UNION | ||
+ | (SELECT MAX(acontent_tstamp) AS latest_ts FROM '.DB_PREPEND.'phpwcms_articlecontent WHERE acontent_visible=1 AND acontent_trash=0 LIMIT 1) | ||
+ | ) AS t1 LIMIT 1'; | ||
+ | |||
+ | $result = _dbQuery($sql); | ||
+ | if(isset($result[0]['latest_ts'])) { | ||
+ | $content["all"] = render_date($content["all"], $result[0]['latest_ts'], 'DATE_UPDATE'); | ||
+ | } else { | ||
+ | // Render Fallback date! | ||
+ | $content["all"] = render_date($content["all"], now(), 'DATE_UPDATE'); | ||
+ | } | ||
+ | } | ||
+ | ?> | ||
+ | </code> |