2010-07-15 29 views
4

我使用Zend Framework的視圖助手不知道,...下面的代碼...Zend框架附加腳本和樣式的HTML5方式

$this->headLink()->prependStylesheet("css/style.css") 
       ->prependStylesheet("css/prettify.css") 
       ->prependStylesheet("css/960.css") 
       ->prependStylesheet("css/text.css") 
       ->prependStylesheet("css/reset.css"); 
$this->headScript()->prependFile("js/site.js") 
        ->prependFile("http://www.google.com/jsapi"); 
echo $this->headLink(); 
echo $this->headScript(); 

這是輸出

<link href="css/reset.css" media="screen" rel="stylesheet" type="text/css" > 
<link href="css/text.css" media="screen" rel="stylesheet" type="text/css" > 
<link href="css/960.css" media="screen" rel="stylesheet" type="text/css" > 
<link href="css/prettify.css" media="screen" rel="stylesheet" type="text/css" > 
<link href="css/style.css" media="screen" rel="stylesheet" type="text/css" > 
<script type="text/javascript" src="http://www.google.com/jsapi"></script> 
<script type="text/javascript" src="js/site.js"></script> 

我怎麼能呼應鏈接和腳本HTML5的方式在那裏我不需要type="text/javascript"rel="stylesheet"所有

+0

我認爲這篇文章可以幫助您: http://www.survivethedeepend.com/zendframeworkbook/en/1.0/setting.the.design.with.zend.view.zend.layout.html.5.and.yahoo .user.interface.library – 2010-07-15 06:03:56

+0

嗯,除非我錯過了一些東西,它們也在使用'appendStylesheet()'它仍然會輸出HTML5中不需要的'type =「text/javascript」'等等。 – 2010-07-15 06:16:50

回答

2

你可以創建你的ouwn幫手,並把它放在您的視圖/助理/ Headlink.php,exrtend原來的Zend框架的人..和公正覆蓋你想做出不同的部分。

可以肯定的是更好的選擇,然後編輯框架文件...

0

zf/library/Zend/View/Helper/HeadLink.php

在功能createDataStylesheet

嘗試改變這一點:

$attributes = compact('rel', 'type', 'href', 'media', 'conditionalStylesheet', 'extras'); 

本(或任何你想要的)

$attributes = compact('type', 'href', 'media', 'conditionalStylesheet', 'extras'); 

如果是工作,你可以讓自己的助手繼承的Zend默認並覆蓋此方法。

而且在JS的情況下,儘量做到:

...->prependFile('yourfile.js', ''); 
+1

糟糕的形式!不要更改庫文件,擴展它們! – michael 2011-03-08 16:17:01

1

只是通過空或空屬性值助手或創建自己的助手(名稱相同,但在不同的命名空間),超載默認標準幫手的行爲。

在框架的源文件中進行更改不是一個好的解決方案。