I wanted to post this in the
viewtopic.php?f=713&t=925142&p=3402477& ... r#p3402477 topic but it is locked and I cannot reply. I spent a few hours looking online for a solution to this issue I was having and finally found a work around.
Issue:
The Nevo Template was loading my css files before all other files (bootstrap, template css) so I could not override either bootstrap or the template css.
Resolution:
I created a "master" view.html.php file that all other view.html.php files would extend. Created a method that would add the stylesheets to an array in the "view". In the "master" view, inside the method "display", I hooked into the JFactory::getApplication()->registerEvent() that would then add the css files to the "document" (JFactory::getDocument() ). I hope this helps anyone in the future looking for a solution and hopefully prevents hours of searching.
Example: master.view.html.php
Code: Select all
class FiltersViewMaster extends JViewLegacy
{
protected $stylesheets = array();
public function __construct($config = array())
{
parent::__construct($config);
//This file will be added to every view
$this->addStylesheet('path/to/css/file.css');
}
//the method to add stylesheet in child views
protected function addStylesheet($url)
{
$this->stylesheets[] = $url;
}
public function display($tpl = null)
{
//add the event hook which then adds the stylesheet to the bottom of
//the JDocument array durring the <head> tag creation
JFactory::getApplication()->registerEvent('onBeforeCompileHead', function () {
$doc = JFactory::getDocument();
foreach ($this->stylesheets as $stylesheet)
{
$doc->addStyleSheet($stylesheet);
}
});
return parent::display($tpl);
}
}