Re: [SMARTY] include_block
Paul Pogonyshev <[email protected]> Thu, 21 Dec 2006 23:28:52 +0200
| Newsgroups | gmane.comp.php.smarty.general |
|---|---|
| Message-ID | <[email protected]> |
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;
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php