Image spezial: Count images

With this small script, the number of images of the CP “Image special” is determined. The result is inserted at the placeholder [%IMG_COUNT%] in the CP-template.


Docu: –
Forum: CP Bilder Spezial: Bilder zählen

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

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

  • $phpwcms['allow_ext_init'] = 1;



PHP:

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

cp_trig_search_filter.php

<?php
/*************************************************************************************
 * 22.03.2011 KH: Count images from CP image special
 *
 * TAG: [%IMG_COUNT%]
*************************************************************************************/
// -----------------------------------------------------------------------------------
// OBLIGATE CHECK FOR PHPWCMS CONSTANTS
if (!defined('PHPWCMS_ROOT')) {die("You Cannot Access This Script Directly, Have a Nice Day.");}
// -----------------------------------------------------------------------------------
 
 
function CP_IMGSPECIAL_count_img ($text, & $data) {
   if($data['acontent_type'] == 31 AND strpos($text, '[%IMG_COUNT%]') ) { // 31 is CP img special
 
 
 
    // Slow and clean
//    $temp  = unserialize($data['acontent_form']);
//    $count = count($temp['images']);
 
 
    // Very fast and dirty
    $count = preg_match_all('/"sort"/', $data['acontent_form'], $temp);
 
 
    $text = str_replace('[%IMG_IMG%]', $count, $text);
 
   }
   return $text;
}
register_cp_trigger('CP_IMGSPECIAL_count_img');
 
?>


english/phpwcms_replacer_rts/frontend_init/cp_trigger/cp-image-special-count-img.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