1259 Posts in 348 Topics by 484 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 837 Views |
-
Setting Order of required themedCSS files

2 November 2011 at 11:09pm
Hi everybody,
I'm loading some CSS files with i.e. <% require themedCSS(layout) %>in my main template (Page.ss). In several included layout templates (i.e. HomePage.ss) I load additional CSS files (i.e. require themedCSS(home)).
In the generated code css files are loaded in reversal order, i.e.
<link rel="stylesheet" type="text/css" href="http://localhost:8060/themes/mysite/css/home.css?m=1320227911" />
<link rel="stylesheet" type="text/css" href="http://localhost:8060/themes/mysite/css/layout.css?m=1320076828" />Since i would prefer to overwrite the general css declarations in layout.css with the specific declarations in home.css, i need to change the order in which the CSS files are loaded.
Anyone any hint if and how this is possible?
Thanx for any answer!
regards
SF -
Re: Setting Order of required themedCSS files

4 November 2011 at 6:39pm
No easy way to control the order for any requirements. You can control order a little easier if you use the Requirements PHP api as thats a bit more predictable.
class Page_Controller extends ContentController {
function init() {
parent::init();Requirements::themedCSS('layout');
}..
class HomePage_Controller extends Page_Controller {
function init() {
parent::init(); // will require page::initRequirements::themedCSS('home');
} -
Re: Setting Order of required themedCSS files

8 November 2011 at 12:23am
Hi Willr,
thx for your answer!
Source Code says:
public function init() {
parent::init();// Note: you should use SS template require tags inside your templates
// instead of putting Requirements calls here. However these are
// included so that our older themes still work
Requirements::themedCSS('layout');
Requirements::themedCSS('typography');
Requirements::themedCSS('form');
}so I don't know if this is deprecated and will be eliminated in future versions?
Currently i'm doing a workaround, passing Silverstripe CSS mechanics with i.e.:
<link rel="stylesheet" type="text/css" href="themes/mysite/css/form.css" media="all" />
<link rel="stylesheet" type="text/css" href="themes/mysite/css/global.css" media="all" />
<link rel="stylesheet" type="text/css" href="themes/mysite/css/typography.css" media="all" />
<% if ClassName == HomePage %>
<link rel="stylesheet" type="text/css" href="themes/mysite/css/home.css" />
<% end_if %>What exactly are the advanteges by loading CSS files via Requirements:: that i miss by doing this?
Regards
SF -
Re: Setting Order of required themedCSS files

23 November 2011 at 7:29am
I've always wondered the same about the message about Requirements. Is this outdated guidance in the now rather dated BlackCandy theme?
-
Re: Setting Order of required themedCSS files

23 November 2011 at 9:45am
Actually what you should be doing these days is using Requirements::combine_files() so you send as few CSS files as possible.
It's personal preference as to use either the PHP requirements api or the template one, personally I think that message in Page.php is wrong. Including it in the PHP code is often the best (or only way) to do it.
-
Re: Setting Order of required themedCSS files

24 November 2011 at 1:39am
Top advice! I'm already combining my Javascript files, so that makes sense to me.
| 837 Views | ||
|
Page:
1
|
Go to Top |



