What you are looking for is called the HeadStyle
view helper. Its manual documentation can be found here.
The HeadStyle
helper's API is consistent will all the Head*
view helpers, and works as such (the following assumes you are in a viewscript):
// Putting styles in order:
// These methods assume the a string argument containing the style rules.
// place at a particular offset:
$this->headStyle()->offsetSetStyle(100, $customStyles);
// place at end:
$this->headStyle()->appendStyle($finalStyles);
// place at beginning
$this->headStyle()->prependStyle($firstStyles);
// Or capturing a block of styles
<?php $this->headStyle()->captureStart() ?>
body {
background-color: <?php echo $this->bgColor ?>;
}
<?php $this->headStyle()->captureEnd() ?>
Note that you do not include the <style>
tags in any of this input. That is generated by the helper itself.
Then, in your layout, simply echo
the helper where you'd like its output:
<head>
<?php echo $this->headLink() ?>
<?php echo $this->headStyle() ?>
</head>