OJS and OMP can be used to run more than one journal or press. We call each journal or press a context. Plugins are usually run within a context but some may run at the site-wide level. You should write your plugins to work whether they are being run at the context or site level.
You can always retrieve the current context from the Request
.
use APP\core\Application;
$context = Application::get()
->getRequest()
->getContext();
In site-wide pages, such as the admin settings or the site-wide journal index page, the context will be null
.
if ($context) {
// The current request is for a journal, press or preprint server
} else {
// The current request is for a site-wide page
}
If your plugin supports a settings page, settings must be saved separately for each context.
$this->updateSetting($context->getId(), 'editorName', 'Daniel Barnes');
Use the Application::CONTEXT_SITE
constant to save settings to the site-wide level.
use APP\core\Application;
$contextId = $context
? $context->getId();
: Application::CONTEXT_SITE;
$this->updateSetting($contextId, 'editorName', 'Daniel Barnes');
Add the isSitePlugin
method to enable the plugin’s settings form in the site-wide plugins list.
class TutorialExamplePlugin extends GenericPlugin
{
// ...
public function isSitePlugin() {
return true;
}
}
Site-wide plugins can also be enabled, disabled and configured for each context.
View more examples.