I wanted to append css stylesheet inside head tag but gets appended to body tag. Here's what i did: i have a controller 'countries' with action 'index' and my view is index.phtml
index.phtml contains:
<?php
$this->headLink()->appendStylesheet($this->baseUrl().'/js/dojo-1.7/dojo/resources/dojo.css')
->appendStylesheet($this->baseUrl().'/js/dojo-1.7/dojox/grid/resources/claroGrid.css');
echo $this->headLink();
This causes the stylesheet to be appended inside body tag. I only want these stylesheet to be appended to this action. I dont want to include this stylesheet inside my layout.phtml How can i do it?
What you've done is correct, but you're echoing headLink() in your view just after adding the stylesheet which is what is outputting the links in the wrong place. Change your code so you have:
In index.phtml:
$this->headLink()->appendStylesheet($this->baseUrl().'/js/dojo-1.7/dojo/resources/dojo.css')
->appendStylesheet($this->baseUrl().'/js/dojo-1.7/dojox/grid/resources/claroGrid.css');
And then in layout.phtml (in the <head>
section where you want the stylesheet links to appear):
echo $this->headLink();