Re: [SMARTY] include_block

From: Date: Thu, 21 Dec 2006 21:28:52 +0000
Subject: Re: [SMARTY] include_block
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-13652@lists.php.net to get a copy of this message
Max Schwanekamp wrote: > Paul Pogonyshev wrote: > > I'd like to propose a block tag `include_block'. > > > > {include_block file="my-cute-side-block"} > > Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do > > eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut > > enim ad minim veniam, quis nostrud exercitation ullamco laboris > > nisi ut aliquip ex ea commodo consequat. > > {/include_block} > > > > And in file `my-cute-side-block': > > > > <div style="float: right; padding: 1ex;"> > > $contents > > </div> > > > > Couldn't this be done with register_block()? > > //quick example lacking error handling... > <?php > $smarty->register_block('include_block','include_block'); > > function include_block($params, $content, &$smarty, &$repeat) { > if(!isset($content) || empty($content)) return; > $smarty->assign('content',$content); > return $smarty->fetch($params['file']); > } Except that `include' can bind additional variables (but that can be added to your code), and, more importantly, assigned values will be left in the caller scope, while `include'-bound variables will be only visible in included file scope. Pai;

« previous php.smarty.general (#13652) next »