17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 3989 Views |
-
conditional css

17 April 2008 at 4:31pm
another newbie question :/ where can I add conditional css ? im working on my first SS website, using higherground theme, and it doesn't seem to be right in IE..
-
Re: conditional css

17 April 2008 at 6:02pm
Hello, irka!
You can add the conditional css in the templates/Page.ss file, just as it's done in the default Blackcandy theme -
Re: conditional css

18 April 2008 at 7:49am
thank you
sorted this problem anyway,,and thanks for the theme
-
Re: conditional css

22 April 2008 at 2:34pm
Another, "better"(?) but slightly more complicated method I've found for doing this is to add your CSS via the Requirements::css static method in your page controller - you can achieve the same results as conditional statements like so:
function init() {
parent::init();
Requirements::css( project() . "/css/default.css");
if($pos = strpos( $_SERVER[ 'HTTP_USER_AGENT' ], 'MSIE' ) ) {
Requirements::css( project() . "/css/ie.css");
$version = substr( $_SERVER[ 'HTTP_USER_AGENT' ], $pos + 5, 3 );
if( $version < 7 ) {
Requirements::css( project() . "/css/ie6.css");
}
if( $version < 6 ) {
Requirements::css( project() . "/css/ie5.css");
}
}
}
}(You would add this to the Page_Controller class in your mysite/Page.php file)
The advantage here is that you can create page types that extend the Page class and they will automatically pick up the inherited CSS files. You could then then add additional, custom stylesheets for a specific page type if you wanted.
-
Re: conditional css

22 April 2008 at 8:38pm
Handy method. You should add this to the CSS page in the documentation - http://doc.silverstripe.com/doku.php?id=css for other peoples reference
-
Re: conditional css

7 May 2008 at 11:48am Last edited: 7 May 2008 11:56am
You can also place this in the Page_Controller function init() and lose the hard coded entries in Page.ss.
Requirements::insertHeadTags("<!--[if IE 6]><style type='text/css'>@import url(themes/" . SSViewer::current_theme() . "/css/ie6.css);</style><![endif]-->");
Requirements::insertHeadTags("<!--[if IE 7]><style type='text/css'>@import url(themes/" . SSViewer::current_theme() . "/css/ie7.css);</style><![endif]-->");
-
Re: conditional css

29 September 2008 at 6:02pm
Hi there - I found I *had* to add the conditional comments into the Page_Controller function in order to achieve the right hierarchy for the conditional stylesheets, using the BlackCandy theme.
When I included the conditional stylesheets in Page.ss they were included *before* the layout.css file, which then over-wrote some of my fixes.
Hope this helps someone!
Y
| 3989 Views | ||
|
Page:
1
|
Go to Top |





