The global layout.php file contains the tags for each page:
<body>
<?php echo $sf_content ?>
</body>
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 ?>
</body>
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(); ?>
or
<?php slot(
'body_id',
sprintf('id="%s"', $sf_params->get('module')))
?>
Here is the solution I used with Symfony 1.2+
Use setSlot() in the action:
$this->getResponse()->setSlot('home_page', 'yes');
Then use get_slot() in the Layout:
<body class="<?php echo has_slot('home_page') ? 'home-page' : 'inner-page' ?>">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With