OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Registering gateway plugin against template hooks

OJS development discussion, enhancement requests, third-party patches and plug-ins.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
Developer Resources:

Documentation: The OJS Technical Reference and the OJS API Reference are both available from the OJS Documentation page.

Git: You can access our public Git Repository here. Comprehensive Git usage instructions are available on the wiki.

Bugzilla: You can access our Bugzilla report tracker here.

Search: You can use our Google Custom Search to search across our main website, the support forum, and Bugzilla.

Questions and discussion are welcome, but if you have a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a technical support question, try the OJS Technical Support subforum.

Registering gateway plugin against template hooks

Postby mj » Wed May 10, 2006 10:46 am

Hi Alec,

Figured I'd post this here so others can learn from it. I'm trying to register a plugin (in the gateway class) against the template display hook you mentioned (TemplateManager::display in classes/template/TemplateManager.inc.php). Specifically, I'm trying to get access to the $additionalHeadData variable when the plugin is registered (to append it with atom/rss feed info).

I'm trying:
Code: Select all
function register($category, $path) {
      $success = parent::register($category, $path);
      if ($success) {
         HookRegistry::register('TemplateManager::display',array(&$this, 'writeMeta'));
         $this->addLocaleData();
         return true;
      }
      return false;
}


But this doesn't seem to be hitting the callback function (writeMeta). I'm sure I'm doing something trivially wrong, but I can't seem to figure it out. Have you got an example of using the hook to do this?

Thanks,
MJ
mj
Site Admin
 
Posts: 304
Joined: Fri Mar 26, 2004 9:32 am
Location: Toronto, Canada

Postby asmecher » Wed May 10, 2006 11:13 am

Hi MJ,

The problem here is probably the scoping of each plugin. Plugin categories are loaded depending on what part of OJS the user is viewing. I expect we'll be refining this somewhat in the future, but as of OJS 2.1.0-1, here are the plugin categories and their scopes:
  • generic: Loaded on every request.
  • auth: Loaded whenever user authentication functions are requested.
  • importexport: Loaded whenever the Journal Manager requests import/export functions; also loaded by the importexport command-line tool.
  • gateways: Loaded whenever http://.../index.php/journalName/gateway/... is requested
Additionally, all plugins are loaded on requests to the Journal Manager's "System Plugins" management area.

The lowest common denominator here is the "generic" category, which is always loaded.

Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 8471
Joined: Wed Aug 10, 2005 12:56 pm

Postby mj » Wed May 10, 2006 11:45 am

asmecher wrote:The problem here is probably the scoping of each plugin. Plugin categories are loaded depending on what part of OJS the user is viewing. I expect we'll be refining this somewhat in the future


I think you're right - the challenge with the feed plugin in particular is that it falls somewhere between a gateway and generic plugin (as Alf originally wrote it). I'll try moving it back to generic and working there - can you just comment on my syntax above to access the $additionalHeadData variable? The TemplateManager in particular is a bit confusing.

My suspicion would be that, if/once we move to a "blocks" framework for dynamic templates, plugins could be bundled with a block to modify display relevant to the plugin, rather than doing it in the plugin itself. Marginally more complicated to install, but far more elegant.

MJ
mj
Site Admin
 
Posts: 304
Joined: Fri Mar 26, 2004 9:32 am
Location: Toronto, Canada

Postby mj » Thu May 11, 2006 12:33 pm

I've been able to implement this as two plugins:

1 (generic) which writes out the appropriate feed headers on the appropriate pages
1 (gateway) which provides the feed functions (atom, rss) for aggregators

This seems like an overly complex way to do it - the alternatives being:

a) omit the generic plugin and edit /templates/common/header.tpl manually (which is also inelegeant if templates change in a newer version).
b) fidn some way to imlpement the feed functions within the generic plugin, although this brings up a path issue (how to call a feed function on a generic plugin by url?)

Am I right in guessing that this is the "only" way to do it, since gateway plugins can't register against TemplateManager hooks?

MJ
mj
Site Admin
 
Posts: 304
Joined: Fri Mar 26, 2004 9:32 am
Location: Toronto, Canada

Postby asmecher » Thu May 11, 2006 1:54 pm

Hi MJ,

In this case, you might be able to go with a purely "generic" plugin. These are able to step in before any execution is delegated and respond to a custom URL by registering against the LoadHandler hook (see the main index.php script). This should only be used when nothing else is available, as it does incur a slight amount of overhead on every request.

Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 8471
Joined: Wed Aug 10, 2005 12:56 pm


Return to OJS Development

Who is online

Users browsing this forum: No registered users and 9 guests