Hi,
I have looked for a solution to add custom template files to themes which would bypass the core templates. I know that this will be available in 3.0, but I also discovered a fairly easy solution to use in 2.4. However, I would like to know if anyone knows of any problems with this solution?
I simply add this code to the theme plugin:
function activate(&$templateMgr) {
$theme_template_id = "myThemeName";
$theme_template_dir = Core::getBaseDir() . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $theme_template_id . DIRECTORY_SEPARATOR . 'templates';
$app_template_dir = Core::getBaseDir() . DIRECTORY_SEPARATOR . 'templates';
$core_template_dir = Core::getBaseDir() . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'pkp' . DIRECTORY_SEPARATOR . 'templates';
$templateMgr->template_dir = array($theme_template_dir, $app_template_dir, $core_template_dir);
$templateMgr->compile_id = $theme_template_id;
if (($stylesheetFilename = $this->getStylesheetFilename()) != null) {
$path = Request::getBaseUrl() . '/' . $this->getPluginPath() . '/' . $stylesheetFilename;
$templateMgr->addStyleSheet($path);
}
}
After adding this I can copy a single .tpl file to the theme folder and it will bypass the core file. Of course I have to use the same folder structure. Also, I do not have to make any changes to the core, everything is handled through the theme plugin.
But as I said, I would be happy to hear if there are any problems with this solution?