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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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:
The problem with doing something this this in the template file is that it’s highly likely that the
headtemplate 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: