The basics of OJS 3.0 plugin development

I need to add additional fields to the submission process. My thought is that I need to build an OJS plugin to extend the submission form, submission storage and display. My first step was to build the equivalent of a HelloWorld as a generic plugin. I did that and posted it to my install of OJS. All of the other plugins have the install step of excuting php tools/upgra.php upgrade and I did that with mine as well.
When I go into the plugin management, the UI hangs (spinning icon as the UI does some Ajax call that doesn’t return a result, an error or stop).
This is the project is it sits: GitHub - dewolfe001/iterSubmission: OJS plugin to allow the addition of tracking data used by Ren&Ref.
Is there a walk-through on naming conventions for plugin development?
Has anyone done a plugin that added new fields to the submission content?

Thanks in advance,

Shawn DeWolfe

Hi @dewolfe001,

Did you check your PHP error log for something that might indicate the problem associated with the endless spinner? That usually means an error got dumped somewhere.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi Alec,
The request to index.php/rekn/$$$call$$$/grid/settings/plugins/settings-plugin-grid/fetch-grid?_=1475700422106 comes back with a 500 error and 0 bytes of content.
With Debug on, the response has references to the other plugins in the debug code (see below), but not the plugin that I added. It’s a given that my plugin is the issue, but what I don’t know is what is it missing that it needs for bare bones functionality. the plugin doesn’t have any particular functionality at this point, but I thought it would have enough to be able to activated and deactivated,

All the best,

Shawn

"

Plugin Gallery

All CategoriesMetadata PluginsAuthorization PluginsBlock PluginsCitation Format PluginsCitation Database Connector PluginsCitation Output PluginsCitation Extraction PluginsGateway PluginsGeneric PluginsImport/Export PluginsOAI Metadata Format PluginsPayment PluginsPublic Identifier PluginsReport PluginsTheme Plugins
Search
Name Description Status
No Items
"

Hi @dewolfe001,

The 500 error suggests you should find something more specific in your web server’s error log. Did you check there?

Regards,
Alec Smecher
Public Knowledge Project Team

I checked there.
My include path was going into pkp lib when it should have looked into classes/submissions

05-Oct-2016 20:44:30 UTC] PHP Warning: require_once(/home/reknojs/public_html/lib/pkp/classes/submission/SubmissionMetadataFormImplementation.inc.php): failed to open stream: No such file or directory in /home/reknojs/public_html/lib/pkp/includes/functions.inc.php on line 25
[05-Oct-2016 20:44:30 UTC] PHP Fatal error: require_once(): Failed opening required ‘/home/reknojs/public_html/lib/pkp/classes/submission/SubmissionMetadataFormImplementation.inc.php’ (include_path=’/home/reknojs/public_html/lib/pkp/lib/vendor/ezyang/htmlpurifier/library:.:/home/reknojs/public_html/classes:/home/reknojs/public_html/pages:/home/reknojs/public_html/lib/pkp:/home/reknojs/public_html/lib/pkp/classes:/home/reknojs/public_html/lib/pkp/pages:/home/reknojs/public_html/lib/pkp/lib/adodb:/home/reknojs/public_html/lib/pkp/lib/phputf8:/home/reknojs/public_html/lib/pkp/lib/pqp/classes:/home/reknojs/public_html/lib/pkp/lib/smarty:.:/usr/lib/php:/usr/local/lib/php’) in /home/reknojs/public_html/lib/pkp/includes/functions.inc.php on line 25

You have:
class IterSubmission extends SubmissionMetadataFormImplementation

I have been under the impression that generic plugins should always extend the GenericPlugin:
class CustomBlockManagerPlugin extends GenericPlugin
class BrowsePlugin extends GenericPlugin
class GoogleAnalyticsPlugin extends GenericPlugin
class HtmlArticleGalleyPlugin extends GenericPlugin
etc.

I’ll second @ajnyga’s observation that you’ll probably want to implement a GenericPlugin. The reference to lib/pkp is coming from this line:

The syntax of the import essentially represents directory paths with dot-separation.

My goal is to create a plugin to add fields to the submission process. For me, “Generic” feels like an incorrect plugin category. What is the ideal category? Has anyone done this before with OJS 3? ie. add fields to the submission forms.

I think that the generic category is the only option you can use in this case.

You just need to use correct hooks.

For example the OpenAIRE plugin adds fields to the submission form, but I do not whether all those hooks work in OJS3 (A new documentation on hooks would be more than welcome)

https://github.com/pkp/ojs/blob/master/plugins/generic/openAIRE/OpenAIREPlugin.inc.php

2 Likes

Since we do not have a documentation regarding hooks, I did a quick version of my own with a grep search. Probably not all of them, but has helped at least me to figure out some hooks.

https://ajnyga.gitbooks.io/ojs3-hooks/

1 Like

That’s fantastic!
Given a thread that said something to the effect of supporting a modification of the core vs. writing a plugin, I went with the former. I have my new code in place, but the altered template (the submissionMetadataFormTitleFields.tpl file) isn’t showing off any of my changes in the submission form. So, I’m still at the drawing board.

Hi @dewolfe001,

Have you tried clearing the template cache?

rm cache/t_compile/*.php

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @ajnyga,

Excellent, thanks for contributing! We’re soon going to start revamping our technical documentation (particularly the outdated OJS Technical Reference), and part of our efforts there will go into making sure that the documentation can stay updated. Our previous approach didn’t lend itself to maintenance well. My hope is that we can move a lot of content into automatically-generated documenting tools like Doxygen – I wonder whether something can be done with the hook registry along those lines…

Regards,
Alec Smecher
Public Knowledge Project Team

Bing! Thanks! That did it. I thought there had to be a cache clearing step and I was running the upgrade script thinking that it would have to clear the cache as a side-effect of introducing the results of an upgrade. Thanks for the tip!

All the best,

Shawn