How to modify a theme without change core files? [OJS 2.4.8-1]

Hi,

That is not default functionality in OJS2. I had this in my old OJS2 theme plugin that enabled me to change the template. I have seen other similar solutions and you could probably find them with a search.

	function getStylesheetFilename() {
		return 'myTheme.css';
	}
	
	function activate(&$templateMgr) {

		$theme_template_id = "myTheme";
		$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);
		}
	}
1 Like