tags:

views:

70

answers:

1

when i pass variables from a controller they are only passed to a template, not a layout surrounding that template.

how do i pass variables to a template?

thanks

+3  A: 

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.

richsage