Failpunk Failpunk - 2 months ago 4x
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?


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')))