4

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"></script>
<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

2
  • i think this article help you : survivethedeepend.com/zendframeworkbook/en/1.0/… Commented Jul 15, 2010 at 6:03
  • hmm unless i missed out something, they are also using what i am using appendStylesheet() it will still output the type="text/javascript" etc which is not required in HTML5? Commented Jul 15, 2010 at 6:16

3 Answers 3

2

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 ...

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

0

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', '');

1 Comment

Bad form! Don't change the library files, extend them!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.