开发者

how do i pass variables to a layout in symfony?

when i pass variables from a controller they are only passed to a template, not a layout surrounding that temp开发者_运维知识库late.

how do i pass variables to a template?

thanks


Use slots.

In your action method:

$this->getResponse()->setSlot("foo", "12345");

In your layout template:

<?php echo get_slot("foo", "default value if slot doesn't exist"); ?>

which will output the slot contents. In this example, you'll see 12345 appear in your layout. If you don't set a slot's value in the action, you can supply a default value to be shown instead in the layout.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜