NAVIGATION
This is an old revision of the document!
Stellt das Erstellungs- und Änderungsdatum des betreffenden CPs bereit. → {CPDATE_CREATEDX} und {CPDATE_CHANGEDX}
===== Beschreibung: =====
Der jeweilige Aufruf sieht so aus, je nach Freigabe im Script (Beispiel: “CPDATE_CREATEDX”):
* {CPDATE_CREATEDX} (Einfache schnelle Version, mit Ausgabeformateinstellungen im Script)
* {CPDATE_CREATEDX} (Einfache Version, mit Ausgabeformat- und Spracheinstellungen Script)
* {CPDATE_CREATEDX:Y-m-d H:i:s} oder {CPDATE_CREATEDX:l, d.m.Y H:i lang=DE} Komfortable jedoch langsamste Version mit allen Parametern im TAG
Im Script wird durch Aus/Endkommentieren festgelegt werden, welches Verfahren Verwendung findet. Es sollten nur die verwendeten Verfahren aktiv sein um Geschwindigkeitsverluste beim Rendern zu vermeiden. Das Script wird für jeden CP einzeln angesprochen.
Dazu kann bestimmt werden in welchen Content Part Typen die TAGs gesucht werden sollen. Wird das einführende IF-Statement mit seiner schließenden Klammer auskommentiert, werden alle CPs untersucht. (Geschwindigkeit!!)
Im Script
—-
Docu: –
Forum: –
Autor: K.Heermann (flip-flop) http://planmatrix.de
CMS Version: >= 1.3x
Version: V1.0 (29.01.2011)
Bedingung: → /config/phpwcms/conf.inc.php
* $phpwcms['allow_ext_init'] = 1;
—-
===== PHP: =====
Datei: /template/inc_script/frontend_init/cp_trig_cp_date.php**
<?php // ------------------------------------------------------------------------------------------- // obligate check for phpwcms constants if (!defined('PHPWCMS_ROOT')) { die("You Cannot Access This Script Directly, Have a Nice Day."); } // ------------------------------------------------------------------------------------------- // // 29.01.11 KH (flip-flop) Returns the CP-creation and modification date // ------------------------------------------------------------------------------------------- function CP_Date_created_change($text, & $data) { // CP filter in use: // - Please enhance the array for your needs, have a look into // - http://www.phpwcms-howto.de/wiki/doku.php/english/technics/internal-function-call/content-part-types // e.g. CPs: 0 => Plain Text, 6 => HTML, 15 => WYSIWYG, 29 => IMAGE <div> // If you don´t need a filter (all CPs will be processed), please disable the if statement and the associated closing parenthesis if( in_array($data['acontent_type'], array(0,6,14,29)) ) { // is used only when the CP-filter should be used. // 1) Very fast but simple with paramter in script without language setting for e.g. day names // e.g. {CPDATE_CREATEDX} $text = str_replace("{CPDATE_CREATEDX}", date('d.m.Y H:i:s',strtotime($data['acontent_created'])), $text); // replace cp date created $text = str_replace("{CPDATE_CHANGEDX}", date('d.m.Y H:i:s',strtotime($data['acontent_tstamp'])), $text); // replace cp date changed // 2) Fast and more complex with parameter and language setting in script // e.g. {CPDATE_CREATEDX} // $text = str_replace("{CPDATE_CREATEDX}", international_date_format('DE', 'l, d.m.Y',strtotime($data['acontent_created'])), $text); // $text = str_replace("{CPDATE_CHANGEDX}", international_date_format('DE', 'l, d.m.Y',strtotime($data['acontent_tstamp'])), $text); // 3) Slower speed for TAG with parameter (and language setting) in TAG // e.g. {CPDATE_CREATEDX:Y-m-d H:i:s} or {CPDATE_CREATEDX:l, d.m.Y H:i lang=DE} $text = render_date($text, strtotime($data['acontent_created']), 'CPDATE_CREATEDX'); $text = render_date($text, strtotime($data['acontent_tstamp']), 'CPDATE_CHANGEDX'); } // is used only when the CP-filter should be used. return $text; } // Possible combinations: 1) only, 2) only, 3) only, 1)and 3), 2) and 3) register_cp_trigger('CP_Date_created_change'); ?>