I am trying to add CSS requirements to the Blog module.
The current approach I have adopted is creating a subclass of the Blog class and Blog_Controller (as well as the BlogPost and BlogPost_Controller) in an attempt to introduce css requirements into the init() function. However, for some reason, I can’t seem to get any reference to these css files to work.
class ProjectsHolder extends Blog{
private static $allowed_children = array(
'ProjectPage'
);
}
class ProjectsHolder_Controller extends Blog_Controller{
public function init(){
parent::init();
Requirements::css("{$this->ThemeDir()}/css/projects.css");
}
}
I have also tried the <% require css %> template syntax. The only way I can get the css to render is by hardcoding the css link tag inside a head tag at the top of the template (which is terrible).
I also noticed SilverStripe’s DataExtension/SiteConfig approach for injecting functionality into classes, which looks like it might be applicable to my situation.
My question is: what is the best practice for styling modules such as the Blog module.
There is clearly something I am missing or not understanding here; any clarification would be much appreciated!