I am using zend framework.
My structure is (only included files and folders needed for this question):
application
>configs
>controllers
>forms
>images
>layouts
>scripts
>layout.phtml
>models
>styles
>style.css
>views
>scripts
>index
>index.phtml
Bootstrap.php
docs
library
logs
public
test
I have got the layout working properly. However, I want to ask a couple of questions in order to get my set up perfect for the way I want it.
- Is
application>styles a good place for the stylesheet to be? If not what’s the recommended? - How do i add the stylesheet to the layout?
- In my layout I have a title tag :
<title>Text</title>. How do I pass values from my controllers to it?
Stylesheets need to be accessible from the browser, so typically you will put these somewhere in the public directory, such as public/css
There are several ways, including placing rel tags in your view/layout, but my preferred option is to use the
viewHelperwithin your controller:$this->view->headLink()->setStylesheet(‘/css/style.css’);
Then your call to
headLink()in the layout file will automatically include the stylesheet.The way I have done this is to use the Zend_Registry in the past. There may be better ways.