If the selected CP/CPs is/are unfilled, there is no output of wrapping DIVs.
E.g.: {WRAP_SHOW_CONTENT:CP, 19:my_class}
or without a class {WRAP_SHOW_CONTENT:CP, 19} -> fallback to the default class WRAP_SHOW_CONTENT
File name: /template/inc_script/frontend_render/rt_wrap_show_content.php
Code: Select all
<?php
// ==================================================================
// {WRAP_SHOW_CONTENT:...:class}. The same like {SHOW_CONTENT: ...
// but with a enclosed div container
// If there is/are a unfilled or unvisible CP/CPs no output is generated
// (and no div wrapper)
//
// E.g.: {WRAP_SHOW_CONTENT:CP, 19: my_class}
// or {WRAP_SHOW_CONTENT:CP, 19} -> fallback to the default class
//
// Default class: WRAP_SHOW_CONTENT
//
// file name: /template/inc_script/frontend_render/rt_wrap_show_content.php
// forum: http://forum.phpwcms.org/viewtopic.php?p=110898#p110898
//
// (c) 07.11.08 Knut Heermann (flip-flop) http://planmatrix.de
// 08.11.08 Updated for a better handling
// ==================================================================
// ------------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
die("You Cannot Access This Script Directly, Have a Nice Day."); }
// ------------------------------------------------------------------
if( strpos($content['all'], '{WRAP_SHOW_CONTENT:') !== FALSE ) {
function func_wrap_show_content($my_param) {
$my_param = str_replace(' ','',$my_param); // kill all spaces
// explode parameter for SHOW_CONTENT and the optional class name
// $my_arr[0] = SHOW_CONTENT parameter
// $my_arr[1] = optional own class name
$my_arr = explode(":",$my_param);
if (!empty($my_arr[1])) { $my_class = $my_arr[1]; } // custom class name = yes
else {$my_class = 'WRAP_SHOW_CONTENT'; } // custom class name = no -> default name
// set the wrapper code
$div_before = '<div class="'.$my_class.'"'.LF;
$div_behind = LF.'</div>';
$string = '';
$string = showSelectedContent($my_arr[0]); // same as SHOW_CONTENT
// Set the wrapper around
if (!$string == '') { $my_replace = $div_before.$string.$div_behind; }
else { $my_replace = ''; }
return $my_replace;
}
// And do it ======
$content["all"] = preg_replace('/{WRAP_SHOW_CONTENT:(.*?)}/e', 'func_wrap_show_content("$1")', $content["all"]);
}
?>
- {WRAP_SHOW_CONTENT:CP, 19}
- {WRAP_SHOW_CONTENT:CP, 19:}
- {WRAP_SHOW_CONTENT:CP, 19:my_class}
[/UPDATE]
[UPDATE 08.11.08 No.2] For avoiding collisions:
- function name changed from func_replace to func_wrap_show_content
[/UPDATE]
Knut