Page 1 of 1

addStyle Question

Posted: Wed Jun 18, 2014 4:57 pm
by xemox
I help my friend to modified his web. I'd like to give his web some changes in css.

I tried to load additional css with this method '$this->document->addStyle'

At default theme it work perfect but in his template it seems wont load properly.

What may cause this things happen? ???

Re: addStyle Question

Posted: Wed Jun 18, 2014 8:27 pm
by IP_CAM
why not just using the (default and custom template) stylesheet.css an add style-content there?
They have to be modified both (the same way) in order to present changes in the default template as well as in the Custom Template.

Ernie

Re: addStyle Question

Posted: Thu Jun 19, 2014 12:24 pm
by xemox
Hi Ernie,
Thanks for your suggestion. However I plan not to modify his core files at this moment.
Beside, the css I need to plant is only for specific page.

xemox

Re: addStyle Question

Posted: Thu Jun 19, 2014 1:58 pm
by agrimabo
for global css, in:

catalog/controller/common/header.php

you could add:

Code: Select all

//load custom css
$this->document->addStyle('catalog/view/theme/' . $this->config->get('config_template'). '/stylesheet/custom.css');
or if you wanna be more specific, you could apply styles to information pages by add the following to:

catalog/controller/information/information.php

Code: Select all

if ( isset($this->request->get['information_id']) && $this->request->get['information_id'] == '10') {
$this->document->addStyle('catalog/view/theme/' . $this->config->get('config_template'). '/stylesheet/pagename.css');
}
in this case, the css file would be loaded if the information id = 10.

Re: addStyle Question

Posted: Thu Jun 19, 2014 5:34 pm
by qahar
xemox wrote:I tried to load additional css with this method '$this->document->addStyle'

At default theme it work perfect but in his template it seems wont load properly.
Open catalog\view\theme\your_theme\template\common\header.tpl
Make sure code below is available.

Code: Select all

<?php foreach ($styles as $style) { ?>
<link rel="<?php echo $style['rel']; ?>" type="text/css" href="<?php echo $style['href']; ?>" media="<?php echo $style['media']; ?>" />
<?php } ?>
For specific page, as agrimabo suggest