Add Theme Setting Tab

Hi everynody

I develope my theme for ojs3 and i want to add some complex setting for my theme, so i decide to add a new tab on journal setting page in the following way:

add the below line in the init function:

HookRegistry::register('Templates::Management::Settings::website', array($this, 'callbackShowWebsiteSettingsTabs'));

add the below function in theme class

function callbackShowWebsiteSettingsTabs($hookName, $args) {
$output =& $args[2];
$request =& Registry::get('request');
$dispatcher = $request->getDispatcher();
$output .= '<li><a name="themeSetting" href="' . $dispatcher->url($request, ROUTE_COMPONENT, null, 'plugins.themes.myTheme.ThemeSettingForm' , 'index') . '">themeSetting</a></li>';
return false;
}

and finally add the below class to my theme folder

import('lib.pkp.classes.handler.PKPHandler');
class ThemeSettingForm extends PKPHandler {

 function __construct() {
   parent::__construct();
 }

 function index($args, $request) {
   echo "TEST";
 }
}

now i see the “themeSetting” tab on journal setting page but when click on it, its empty and when i open its link on new tab it give me the 404 error.

can anybody help me
thanks

Hi @Azerilatama,

Off the top of my head, I think you’ll have trouble doing that with a theme plugin. Each plugin category has loading conventions of its own, and I believe the theme plugin gets loaded too late to introduce its own handler in the way that generic plugins do.

Off the top of my head, there are few options…

  • Turn your theme plugin into a generic plugin that also loads a theme plugin. (Other plugins use similar techniques – see e.g. the web feed plugin, which includes both a block and a gateway plugin.)
  • Stick with the normal pop-up settings modal.

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

thanks dear @asmecher
the “web feed plugin” is a very good tutorial plugin for my case.
can you also introduce me a sample for the second way (Stick with the normal pop-up settings modal)

Hi @Azerilatama,

Many plugins have settings forms – though currently none of the theme plugins that I’m aware of. The web feed plugin has a small settings form in a modal, so it could again serve as an example.

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like