Zend Framework附加Scripts&样式表HTML5方式

时间:2010-07-15 05:43:05

标签: zend-framework html5

我想知道使用Zend Framework的视图助手,...下面的代码......

$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"所有

3 个答案:

答案 0 :(得分:2)

你可以创建你的ouwn助手,并把它放在你的视图/助手/ Headlink.php中,远离原始的Zend Framework那些......并且只是覆盖你希望做出不同的部分。

确保更好的选择,然后编辑框架文件...

答案 1 :(得分:1)

只需将空或空属性值传递给帮助程序或创建自己的帮助程序(具有相同的名称,但在不同的名称空间中),重载标准帮助程序的默认行为。

在框架的源文件中进行更改不是一个好的解决方案。

答案 2 :(得分: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', '');
相关问题