Failpunk Failpunk - 1 year ago 64
PHP Question

How can you pass a parameter from an action to the layout in Symfony

The global layout.php file contains the tags for each page:

<?php echo $sf_content ?>

But for all my inner HTML pages of the site, a class is applied to the body tag:

<body class="inner-page">
<?php echo $sf_content ?>

How can I pass in a class to the layout from different templates?

Answer Source

in your layout.php

<body <?php if (!include_slot('body_id')): ?>id="default"<?php endif; ?>>

in your templates :

<?php slot('body_id') ?>id="bla"<?php end_slot(); ?>


<?php slot(
  sprintf('id="%s"', $sf_params->get('module')))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download