If you ever developed a theme for OJS you already noticed it could be a little tricky.
PKP guys are refactoring html structure and css files and it task will be easier soon (OMP it's the reference every OxS will follow) but also with the improvement, there will be some situations you will like to load an specific CSS file in an specific ojs page (pe: Help pages? Home? Archive? ArticleView?...)
Is this possible? Of course... you just need to overwite your "activate" method in you /plugins/themes/yourtheme/YourThemePlugin.inc.php.
Sounds difficult? No worry, just edit the file I mention and modify the "activate" function with the following code:
- Code: Select all
function activate(&$templateMgr) {
if (($stylesheetFilename = $this->getStylesheetFilename()) != null) {
//Loads theme's base stylesheet:
$path = Request::getBaseUrl() . '/' . $this->getPluginPath() . '/' . $stylesheetFilename;
$templateMgr->addStyleSheet($path);
// Getting info about the loaded page.
$context = Request::getCompleteUrl();
//Loads help.css in help pages.
if (strpos($context,'help/') !== FALSE) {
$path = Request::getBaseUrl() . '/' . $this->getPluginPath() . '/' . 'help.css';
$templateMgr->addStyleSheet($path);
}
//Loads articleView.css in article's page.
if (strpos($context,'article/view') !== FALSE) {
$path = Request::getBaseUrl() . '/' . $this->getPluginPath() . '/' . 'articleView.css';
$templateMgr->addStyleSheet($path);
}
}
}
Don't forget to create help.css and ariticleView.css files (in your theme's root folder).
Cheers,
m.
