2009-07-24 35 views
3

我想编写一个内部样式表中的Zend Framework作为这样如何在Zend Framework中编写内部样式表?

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

一个观点我明白,我可以写使用$this->view->headLink()->appendStylesheet('style.css');

外部样式表但是我无法找到一个方法来写一个内部样式表。有任何想法吗?

+0

请澄清你所说的“内部样式表”的意思。 – hobodave 2009-07-24 02:41:21

+0

编辑的问题,以澄清内部样式表 – Marcel 2009-07-24 02:47:27

回答

13

你在找什么叫做HeadStyle查看帮手。其手册文档可以在here找到。

HeadStyle助手的API是将所有的Head*视图助手保持一致,这样的工作(以下假设你是在一个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() ?> 

注意,你不包括任何<style>标签这个输入。这是由助手本身产生的。 然后,在你的布局,只需echo助手,你想它的输出:

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

谢谢。 $ this-> headStyle() - > captureStart()和$ this-> headStyle() - > captureEnd()就是我正在寻找的。 – Marcel 2009-07-24 08:08:42

相关问题