Table of Contents

CP-Date

Provides the creation and modification date of the CPs.
→ {CPDATE_CREATEDX} und {CPDATE_CHANGEDX}

Description:

The respective call looks like this, depending on the release of the script. (Example: “CPDATE_CREATEDX”):

  • {CPDATE_CREATEDX} (Simple fast version, with output format settings in the script)
  • {CPDATE_CREATEDX} (Simple Version, with output format and language settings in the script)
  • {CPDATE_CREATEDX:Y-m-d H:i:s} or {CPDATE_CREATEDX:l, d.m.Y H:i lang=DE} Comfortable but slowest version with all parameters in the TAG

In the script is determined by off/uncomment the numbered script blocks, which method is applied. Only the used procedures should be active to avoid loss of speed when rendering. The script will be addressed individually for each CP!

Possible combinations of the individual script blocks: 1) only, 2) only, 3) only, 1) and 3), 2) and 3)

Additionally you can determine which Content part Types will be searched for TAGs. By commenting the introducing IF-Statement with it's closing bracket all CPs will be searched. (speed!!)


Docu: –
Forum: –

Author: K.Heermann (flip-flop) http://planmatrix.de
CMS Version: >= 1.3x
Version: V1.0 (29.01.2011)

Condition:/config/phpwcms/conf.inc.php

  • $phpwcms['allow_ext_init'] = 1;



PHP:

File: /template/inc_script/frontend_init/cp_trig_cp_date.php

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');
?>


english/phpwcms_replacer_rts/frontend_init/cp_trigger/cp-date.txt · Last modified: 2018/06/03 18:09 (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