Friday, June 25, 2010

Add styling to a Zend Framework based web application

Ordinary <link> tag won’t help you to add style sheets to a view script of a MVC application which uses  Zend Framework. This is because URL doesn’t direct to the actual root directory. But with help of a view helper, called baseUrl() it'll be easy to solve this problem.
Add following 3 lines of code to the <head>; section of your .phtml (view) script. Remember, in this case your CSS files should be in yoursite/public/css

echo $this->headMeta(); 
<head>
   echo $this->headMeta();
   echo $this->headTitle();
   echo $this->headLink()->prependStylesheet($this->baseUrl().'/css
        /mystyle.css');
<head>

No comments: