Table of Contents

CP-Comment output

Supports the output of the CP comment field with the help of a TAG in text or template.
TAG: → {CPCOMMENT}

Description:

If the TAG {CPCOMMENT} is set in CP text or template, at this point the content of the associated comment field is displayed.

I have set the class <span="cpcomment"> .... </span> as a wrapper for the comment output.

Additionally you can determine which CP´s will be searched for TAGs. (IF statement …)

  1. Filter by unique category id´s
  2. Filter by unique article id´s
  3. Filter by unique cp id´s
  4. Or use a combination of the queries shown above.

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 (20.02.2011)

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

  • $phpwcms['allow_ext_init'] = 1;



PHP:

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

cp_trig_comment_output.php

<?php
// -------------------------------------------------------------------------------------------
// obligate check for phpwcms constants
  if (!defined('PHPWCMS_ROOT')) {
    die("You Cannot Access This Script Directly, Have a Nice Day."); }
// -------------------------------------------------------------------------------------------
//
// 20.02.11 KH (flip-flop) Out of the comment field by TAG {CPCOMMENT}
// -------------------------------------------------------------------------------------------
 
 
   function CP_Comment_field_Output($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
 
      // Second example for processing only cp´s are located in specific category
      // Third example for processing only cp´s are located in specific articles
      // Forth example for processing only cp´s with it´s unique cp id
 
 
 
      // 1) Filter by Content Part Types
//      if( in_array($data['acontent_type'], array(0,6,14,29)) ) { // is used only when the CP-filter is needed.
 
      // 2) Filter by category
//      if( in_array($GLOBALS["content"]["struct"][$GLOBALS["content"]["cat_id"]]["acat_id"], array(0,6,14,29)) ) { // is used only when the CP-filter is needed.
 
      // 3) Filter by unique article id´s
//      if( in_array($data['acontent_aid'], array(0,6,14,29)) ) { // is used only when the CP-filter is needed.
 
      // 4) Filter by unique cp id´s
      if( in_array($data['acontent_id'], array(10,6,14,29)) ) { // is used only when the CP-filter is needed.
 
        // Replaces the TAG and put a class around it.
        $text = str_replace("{CPCOMMENT}",       '<span class="cpcomment">'.$data['acontent_comment'].'</span>', $text);  // replace cp Comment
 
      } // Used only if a CP-filter is in use.
 
      // Delete all unused TAGs
      else
        $text = str_replace("{CPCOMMENT}",       '', $text);
 
 
      return $text;
   }
 
 
   register_cp_trigger('CP_Comment_field_Output');
?>


english/phpwcms_replacer_rts/frontend_init/cp_trigger/cp-comment-output.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