Php 如何在Zend框架中编写内部样式表?
我想为Zend框架中的视图编写一个内部样式表Php 如何在Zend框架中编写内部样式表?,php,css,zend-framework,Php,Css,Zend Framework,我想为Zend框架中的视图编写一个内部样式表 <head> <style type="text/css" media="all"> body{ background: #FFFFFF; } </style> </head> 正文{背景:#FFFFFF;} 我知道我可以使用$this->view->headLink()->appendStylesheet('style.css')编写外部样式表 但是,我找不到一种编写内
<head>
<style type="text/css" media="all">
body{ background: #FFFFFF; }
</style>
</head>
正文{背景:#FFFFFF;}
我知道我可以使用$this->view->headLink()->appendStylesheet('style.css')编写外部样式表代码>
但是,我找不到一种编写内部样式表的方法。有什么想法吗?您正在寻找的被称为HeadStyle
视图助手。可以找到它的手动文档
HeadStyle
helper的API与所有的Head*
视图helper是一致的,并且是这样工作的(以下假设您在viewscript中):
请澄清“内部样式表”的含义。编辑问题以澄清内部样式表谢谢$这个->头样式()->captureStart()和$this->头样式()->captureEnd()正是我想要的。
// 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() ?>
<head>
<?php echo $this->headLink() ?>
<?php echo $this->headStyle() ?>
</head>