A new tag cms:unset becomes handy for hard-core diggers like me. Sometimes I don't want a variable with a huge html content mess up output of cms:dump_all tag. I am sure others may find their own use-cases.

Code: Select all

// cms:unset tag
// <cms:unset myvar />
// <cms:unset 'myvar' />
// <cms:unset var='myvar, myvar2' />
$FUNCS->register_tag( 'unset', 'tag_unset' );
function tag_unset( $params, $node ){
    global $CTX;
    if( count($node->children) ) {die("ERROR: Tag \"".$node->name."\" is a self closing tag");}
    $vars = $node->attributes['0']['value'];
    $vars = is_scalar($vars) ? $vars : $params[0]['rhs'];

    foreach( array_map( "trim", explode( ',', $vars )) as $varname ){
        unset( $CTX->ctx['0']['_scope_'][$varname] );