views:

49

answers:

3

i am wondering using Zend Framework's view helpers, ... code below ...

$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();

this is output

<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"&gt;&lt;/script&gt;
<script type="text/javascript" src="js/site.js"></script>

how can i echo links and scripts the html5 way where i do not need type="text/javascript" and rel="stylesheet" all that

+1  A: 

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

in function createDataStylesheet

try to change this:

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

to this (or anything you want)

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

If it is working you can make your own helper that inherit Zend default and override this method.

And in case of js try to do:

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

You could create your ouwn helper, and put it in your view/helpers/Headlink.php, exrtend the original Zend Framework ones .. and just override the part you wish to make different.

For sure a better option then editing Framework files ...

Sinisa Valentic
+1  A: 

Just pass empty or null attribute values to the helper or create your own helper (with the same name, but in different namespace), overloading the default behavior of the standard helper.

Making changes in source files of the framework is not a good solution.

takeshin