开发者

how do i pass variables to a layout in symfony?

开发者 https://www.devze.com 2023-01-02 09:37 出处:网络
when i pass variables from a controller they are only passed to a template, not a layout surrounding that temp开发者_运维知识库late.

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

精彩评论

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