Changing a specific class in default.ctp
1 answer
In your layout, you can modify the static class to include the simple if / else statement shown below:
<main class="main-content">
<div class="<?php echo (isset($layout_class_var)) ? $layout_class_var : 'post-content'; ?>">
<?php echo $this->Session->flash(); ?>
<?php echo $this->fetch('content'); ?>
</div>
</main>
Then, every time you want to set a new class name instead of the default post-content class , just set the class name you want in the $ layout_class_var variable on your controller action:
public function someAction() {
//set layout class to 'new-layout-class'
$this->set('layout_class_var', 'new-layout-class');
}
+2
source to share