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
File: /template/inc_script/frontend_init/cp_trig_imagespecial_count_img.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'); ?>