2009-07-24 42 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

相關問題