Hi,
I want to add a css id to the body tag for each separate view.
What is the best way to do this automatically?
Thanks,
Julian
Hi,
I want to add a css id to the body tag for each separate view.
What is the best way to do this automatically?
Thanks,
Julian
One idea would be to create a new attribute in Controller.php… something like
public bodyID;
In your controller or view… you can set it as
$this->bodyID='the id you need';
and in the main template you just echo that value like
<body <?php echo $this->bodyID; ?>
Hi,
This sounds like a good idea. I will try that out!
Thanks,
J
Ops just noted that the body tag is not closed and not complete…
should be
<body id="<?php echo $this->bodyID; ?>">
in the case that bodyID is not set it would render an empty id like <body id="">
if you don’t like this ( like me ) than you can use something like this
<?php
$bodyID='';
if($this->bodyID!==null)
$_bodyID=' id="'.$bodyID.'"';
?>
<body<?php echo $_bodyID; ?>>
Yep, doing it like mdomba suggested is the easiest way.