Thank you so much for this thread! I was just encountering this exact issue on a fresh installation of OJS 3.1.2-1 from the downloads page.
Here is what I did to fix the issue on my installation, based on the information provided by @Vitaliy:
- Opened my /lib/pkp/classes/plugins/Plugin.inc.php file in a text editor
- Opened the new version of the file in a web browser: https://github.com/pkp/pkp-lib/blob/eaada3cd59172f2b387b36fd13251a3121d0cda3/classes/plugins/Plugin.inc.php
- Grabbed the following code from the file on GitHub:
/**
* Call this method when an enabled plugin is registered in order to override
* template files. Any plugin which calls this method can
* override template files by adding their own templates to:
* <overridingPlugin>/templates/plugins/<category>/<originalPlugin>/templates/<path>.tpl
*
* @param $hookName string TemplateResource::getFilename
* @param $args array [
* @option string File path to preferred template. Leave as-is to not
* override template.
* @option string Template file requested
* ]
* @return boolean
*/
public function _overridePluginTemplates($hookName, $args) {
$filePath =& $args[0];
$template = $args[1];
$checkFilePath = $filePath;
// If there's a templates/ prefix on the template, clean up the test path.
if (strpos($filePath, 'plugins/') === 0) $checkFilePath = 'templates/' . $checkFilePath;
// If there's a lib/pkp/ prefix on the template, test without it.
$libPkpPrefix = 'lib' . DIRECTORY_SEPARATOR . 'pkp' . DIRECTORY_SEPARATOR;
if (strpos($checkFilePath, $libPkpPrefix) === 0) $checkFilePath = substr($filePath, strlen($libPkpPrefix));
// Check if an overriding plugin exists in the plugin path.
if ($overriddenFilePath = $this->_findOverriddenTemplate($checkFilePath)) {
$filePath = $overriddenFilePath;
}
return false;
}
/**
* Recursive check for existing templates
* @param $path string
* @return string|null
*/
private function _findOverriddenTemplate($path) {
$fullPath = sprintf('%s/%s', $this->getPluginPath(), $path);
if (file_exists($fullPath)) {
return $fullPath;
}
// Backward compatibility for OJS prior to 3.1.2; changed path to templates for plugins.
if (($fullPath = preg_replace("/templates\/(?!.*templates\/)/", "", $fullPath)) && file_exists($fullPath)) {
if (Config::getVar('debug', 'deprecation_warnings')) {
trigger_error('Deprecated: The template at ' . $fullPath . ' has moved and will not be found in the future.');
}
return $fullPath;
}
// Recursive check for templates in ancestors of a current theme plugin
if (is_a($this, 'ThemePlugin')
&& $this->parent
&& $fullPath = $this->parent->_findOverriddenTemplate($path)) {
return $fullPath;
}
return null;
}
- Replaced the following code in my local file, with the code above:
/**
* Call this method when an enabled plugin is registered in order to override
* template files. Any plugin which calls this method can
* override template files by adding their own templates to:
* <overridingPlugin>/templates/plugins/<category>/<originalPlugin>/templates/<path>.tpl
*
* @param $hookName string TemplateResource::getFilename
* @param $args array [
* @option string File path to preferred template. Leave as-is to not
* override template.
* @option string Template file requested
* ]
* @return boolean
*/
public function _overridePluginTemplates($hookName, $args) {
$filePath =& $args[0];
$template = $args[1];
$checkFilePath = $filePath;
// If there's a templates/ prefix on the template, clean up the test path.
if (strpos($filePath, 'plugins/') === 0) $checkFilePath = 'templates/' . $checkFilePath;
// If there's a lib/pkp/ prefix on the template, test without it.
$libPkpPrefix = 'lib' . DIRECTORY_SEPARATOR . 'pkp' . DIRECTORY_SEPARATOR;
if (strpos($checkFilePath, $libPkpPrefix) === 0) $checkFilePath = substr($filePath, strlen($libPkpPrefix));
// Check if an overriding plugin exists in the plugin path.
$checkPluginPath = sprintf('%s/%s', $this->getPluginPath(), $checkFilePath);
if (file_exists($checkPluginPath)) {
$filePath = $checkPluginPath;
// Backward compatibility for OJS prior to 3.1.2; changed path to templates for plugins.
} else {
$checkPluginPath = preg_replace("/templates\/(?!.*templates\/)/", "", $checkPluginPath);
if (file_exists($checkPluginPath)) {
if (Config::getVar('debug', 'deprecation_warnings')) {
trigger_error('Deprecated: The template at ' . $checkPluginPath . ' has moved and will not be found in the future.');
}
$filePath = $checkPluginPath;
}
}
return false;
}
- Refreshed the journal website and the CSS loaded in exactly as I expected.
Thanks!