NAVIGATION
This shows you the differences between two versions of the page.
deutsch:ersetzer_rts:frontend_render:datum-letztes-update [2011/04/25 16:51] Knut Heermann (flip-flop) |
deutsch:ersetzer_rts:frontend_render:datum-letztes-update [2020/03/23 11:05] (current) Uwe Tholey |
||
---|---|---|---|
Line 27: | 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 Anwendungfall ist dies jedoch unwichtig).// | + | **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:i}** \\ | TAG: **{DATE_UPDATE}** oder z.B. **{DATE_UPDATE:d.m.Y H:i}** \\ | ||
Line 37: | 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 81: | 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 115: | Line 119: | ||
$sql = "SELECT UNIX_TIMESTAMP(max(article_tstamp)) AS max_article_tstamp "; | $sql = "SELECT UNIX_TIMESTAMP(max(article_tstamp)) AS max_article_tstamp "; | ||
- | // Nur fuer MySQL Engines geeignet die auch im SELECT Unterabfragen unterstuetzen | + | // Nur fuer MySQL Engines geeignet die auch im SELECT Unterabfragen unterstuetzen |
- | // Only suitable for MySQL Engines that also support subqueries in SELECT statement | + | // Only suitable for MySQL Engines that also support subqueries in SELECT statement |
/* | /* | ||
$sql .= ",article_id, "; | $sql .= ",article_id, "; | ||
Line 148: | Line 152: | ||
- | // ------------------ Special case "home" | + | // ------------------ Special case article in "home" |
// Category settings in: $content["struct"]['0'] | // Category settings in: $content["struct"]['0'] | ||
Line 169: | Line 173: | ||
if (isset($result0['0']['max_article_tstamp']) AND ($result0['0']['max_article_tstamp'] > $result['0']['max_article_tstamp']) ) | 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']; | $result['0']['max_article_tstamp'] = $result0['0']['max_article_tstamp']; | ||
+ | // ------------------ | ||
$my_date = (isset($result['0']['max_article_tstamp'])) ? $result['0']['max_article_tstamp']: time(); | $my_date = (isset($result['0']['max_article_tstamp'])) ? $result['0']['max_article_tstamp']: time(); | ||
Line 191: | 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> |