I want to add a CSS file inside tag from template (.phtml) file in magento. Is it possible ?
There is a reason to do so: the CSS file name is dynamic, so I don't know until the template executes. Is it possible to do so?
I want to add a CSS file inside tag from template (.phtml) file in magento. Is it possible ?
There is a reason to do so: the CSS file name is dynamic, so I don't know until the template executes. Is it possible to do so?
To add a CSS file from a controller after you've loaded the layout, but before you've rendered the layout, you'd do something along the lines of:
public function indexAction() {
$this->loadLayout();
$head = Mage::app()->getLayout()->getBlock('head');
$head->addItem('skin_css', 'css/additional.css');
$this->renderLayout();
}
The problem with doing something this this in the template file is that it's highly likely that the head template has already been rendered, and so the additional directives you give the block instance are useless because they are too late.
Just use a layout file and do the following:
<?xml version="1.0">
<layout>
<default>
<reference name="head">
<action method="addItem"><type>skin_css</type><file>css/additional.css</file></action>
</reference>
</default>
</layout>
page.xmllocal.xml in your theme directory and making the changes there.yes it is possible and nothing different just like this:
<head>
<link rel="stylesheet" href="<?php echo $this->getSkinUrl(); ?>css/yourCssfile.css" type="text/css" />
</head>
it will pick ur theme folder from skin/themefolder/css/yourCss
hi work fine this type called css in my first project http://satyak.co/ go on head.phtml after all css and js and call getSkinUrl('css/bootstrap.css');?>" rel="stylesheet">