Posted on: 01/09/15 10:43am
By: syco
Hello!
I hope this is the right place for my question. I was wondering if there was an easy way to handle a plugin's CSS with my own theme.
eg: I'd like to customise the forum and calendar plugins but without breaking other themes by fiddling directly with the plugin's original style (and have to re-fix it each time the plugin is updated for example).
Re: Override plugin css?
Posted on: 12/17/15 11:33am
By: ::Ben
You can create your own custom theme based on a default theme. See
here
In your yourtheme/functions.php file add
Text Formatted Code
/**
* Return an array of CSS files to be loaded
*/
function theme_css_yourtheme()
{
global $_CONF;
return array(
array(
'name' => 'custom',
'file' => '/layout/' . $_CONF['theme'] . '/css/custom.css',
'attributes' => array('media' => 'all'),
'priority' => 200
)
);
}
and make any custom css in the yourtheme/css/custom.css
Re: Override plugin css?
Posted on: 12/17/15 04:26pm
By: Laugh
Actually with the release of Geeklog 2.1.1 plugins can support multiple themes and a set of plugin templates can be based on other templates. The core plugins and the forum support this. The forum is the only plugin at the moment that actively uses this. We added this so plugins can be upgraded with out wiping out any custom template and css changes.
Take a look at the plugins/forum/template directory. You will see a default and denim directory. If the denim theme is active the forum plugin will use the templates found in the denim directory. If the template is not found it will use the one found in the default directory. The default directory must contain all required template files and is used if a template directory is not found. For plugins css and javascript works in a similar way under:
public_html/forum/css
public_html/forum/javascript
The plugin template theme directory can also have a functions.php file now. Take a look at:
plugins/forum/template/denim
for an example.
If you are developing a Geeklog theme if you want you could also include the template files for the plugin right in the root of the theme directory under a directory named after the plugin (like forum). You can only include the template files you want changed as if any are missing it will fall back to the default template files for the plugin.
More information can be found on the wiki
http://wiki.geeklog.net/index.php/Theme_Developers_Guide#Theme_Specific_Plugin_Templates[*1] .
Re: Override plugin css?
Posted on: 12/17/15 04:34pm
By: Laugh
I also forgot to mention. The plugin template system is smart enough to also check if the Geeklog theme you are using has theme default. If it does the plugin will check first if templates/css/javascript exists for the theme, then the theme default, and if those directories do not exist it will then grab it from the plugin default directory (the terminology can be a little confusing at first
Re: Override plugin css?
Posted on: 12/17/15 10:01pm
By: syco
Thanks to both of you
The second solution was what i thought of back then, but it would have implied to rewrite each plugin to act like the new forum plugin
If all future plugins could work the same way it would be perfect
Re: Override plugin css?
Posted on: 12/18/15 07:04am
By: Laugh
It actually wouldn't take long for most developers to convert their plugins as all you need to do is change a few lines of code where ever the plugin specifies a location of the template, css and javascript files.