Bilder spezial: Anzahl Bilder

Mit diesem kleinen Script wird die Anzahl der Bilder des CPs “Bilder spezial” ermittelt und das Ergebnis am Platzhalter [%IMG_COUNT%] im CP-Template eingesetzt.


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

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

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

  • $phpwcms['allow_ext_init'] = 1;



PHP:

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


deutsch/ersetzer_rts/frontend_init/cp_trigger/cp-bilder-spezial-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