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.
精彩评论