开发者

templates in symfony

开发者 https://www.devze.com 2023-02-20 14:39 出处:网络
Hy, I\'m look for a way to do this on symfony: I\'ve to use a \"box\" a bit every where on my site... this box is resizable ... so the html/css is not simple... and i don\'t want to copy/pa开发者_如何

Hy, I'm look for a way to do this on symfony:

I've to use a "box" a bit every where on my site... this box is resizable ... so the html/css is not simple... and i don't want to copy/pa开发者_如何学编程ste it every where and the content of this box is not constant at all... so its not possible to make a partial template with a object variable... and pass all the content on a variable it's a bit annoying.

someyhing like this would be great:

<?PHP begin("mytemplate") ?>
"html content"
<?PHP end ?>

thanks for your help


Everywhere you need this "box" try this:

include_partial('mymodule/mypartial', array('variable1' => 'value1', 'variable2' => 'value2'));

and in your "mymodule/templates/_mypartial.php" use it like:

<div class="box"><?php echo $variable1 ?></div>


If you don't want to use partials you can use components and define each variable into the component action. Check Symfony's Components Slots (this is for v1.2 but works in v1.4).

0

精彩评论

暂无评论...
验证码 换一张
取 消