How to write internal style sheets in Zend Framework?

I would like to write an internal stylesheet for presentation in the Zend Framework as such

<head>
   <style type="text/css" media="all"> 
      body{ background: #FFFFFF; }
   </style>
</head>

I understand that I can write an external stylesheet using $this->view->headLink()->appendStylesheet('style.css');

However, I cannot find a way to write an internal stylesheet. Any ideas?

+3
source share
1 answer

What you are looking for is called a viewing assistant HeadStyle. Its reference documentation can be found here .

The helper API is HeadStylecompatible with all view helpers Head*and works as such (assuming you are in viewcript):

// 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() ?>

, <style> . . echo , :

<head>
    <?php echo $this->headLink() ?>
    <?php echo $this->headStyle() ?>
</head>
+13

Source: https://habr.com/ru/post/1713411/


All Articles