3214 Posts in 848 Topics by 810 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 273 Views |
-
including CSS in my module

22 September 2012 at 1:14am Last edited: 22 September 2012 1:14am
I've made my own module, and now I want to add some css for better data presentation. I've got following file structure:
- sigurnijiinternet
-- css
--- siginternet.css
-- templates
--- RedButtonPage.ss
-- code
--- RedButtonPage.phpI've tried including
into template file. Also with calling themedCSS(siginternet.css) function. I've tried calling Requirements class' css and themedCSS functions from init function of RedButtonPage_controller within RedButtonPage.php file:<% require css(sigurnijiinternet/css/siginternet.css) %>
public function init() {
parent::init();
Requirements::themedCSS("siginternet");
// Requirements::css("/www/sigurnijiinternet/css/siginternet.css");
// parent::init();
}Notice the variation on order of calling these functions. Furthermore, I've also tried changing user permissions on all mentioned files, but I never get any css included into the resulting html.
Any hints?
-
Re: including CSS in my module

22 September 2012 at 4:29am Last edited: 22 September 2012 4:30am
You probably already found the following documentation for SS2.4 and SS3:
- http://doc.silverstripe.org/framework/en/2.4/reference/requirements
- http://doc.silverstripe.org/framework/en/reference/requirements<% require css(sigurnijiinternet/css/siginternet.css) %>
Should work... You probaly also know to ?flush=1 if you change a template...
Requirements::css("sigurnijiinternet/css/siginternet.css");
Should work from your pagecontroller init() like you do (but not with the www though, but up from the root of your website)
ThemedCSS now, that will only work if you place your css file in your theme...
-
Re: including CSS in my module

25 September 2012 at 10:33pm
martimiz,
Yes, I've checked the documentation, and also tried flushing. I also tried various paths (absolute, relative...) to the css file. What I noticed is that if I don't Include all html code in template file (html, head, body tag....) then css doesn't get included. When I struct template file good, then it gets included - this is okay.
But, I also noticed that some standard css files get included, like default theme's layout.css, js langugage file and so on. I've removed them with Requirements::clear. I guess that's why it's discouraged to include css, js and other files in controller's::init function.
P.S. Maybe a notice could be added in documentation that full html code must be put in template file for template requirements to work?
Cheers
| 273 Views | ||
|
Page:
1
|
Go to Top |

