OJS 3.1.2: Changes for Block Plugins

@asmecher,
are there any information available about the changes for block plugins? After upgrade (3.1.0-4 to 3.1.2) our custom plugin leads to white page.
(I already moved templates to /templates.)

PHP error thrown:
[14-May-2019 18:34:26 Europe/Berlin] PHP Fatal error: Uncaught → Smarty: undefined extension class ‘Smarty_Internal_Method_Assign_By_Ref’ ←
thrown in /[…]/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_internal_undefined.php on line 62

Thanks, Tobias

Hi @twa,

Check your PHP error log for details – I suspect you’ll find an error there.

The big change starting with 3.1.2 is the way templates are referred to in the source code. To get the proper location of a template file that’s distributed inside a plugin, you’ll need to use e.g.:
Plugin::getTemplateResource('templateFilename.tpl')
…instead of e.g.:
Plugin::getTemplatePath() . 'templateFilename.tpl'

See pkp/pkp-lib#3242 Update for Smarty3 · pkp/staticPages@8bf068d · GitHub for an example of a change that applies this to an existing plugin.

Regards,
Alec Smecher
Public Knowledge Project Team

2 Likes

(Ah, I see there’s now an error message in the above post. It looks like you’re using assign_by_ref in your plugin class – if you really need to use a reference, then change it to assignByRef. But more likely it’s not a necessary use of references, so you can just use assign.

This is a change in syntax introduced by Smarty v3.)

1 Like

Taking advantage of the discursing my error log refers to the theme plugin in the version change from ojs 3.1.1.4 to 3.1.2:
PHP Fatal error: Uncaught Error: Call to undefined method SiteSetupForm :: getFormLocale () in /var/www/html/ojsteste/lib/pkp/classes/admin/form/PKPSiteSettingsForm.inc.php:135

Thanks, @asmecher – that did it! And assign was enough!

Hi @monicalp,

See: OMP 3.1.2 Call to undefined method SiteSetupForm::getFormLocale() · Issue #4571 · pkp/pkp-lib · GitHub

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

@asmecher one further question regarding plugin development:
I want to add a settings forum to our custom plugin for handling some basic values. I tried to understand the settings in generic/CitationStylePlugin and pubIds/DOI, but they are very complex. Searching the forum and Web brought me no valuable hint on how to implement this.

Are there any simple plugins around, which show how to do a basic settings form?

Thanks, Tobias

Hi @twa,

If you’re looking for an example of a settings form, I’d suggest picking a simpler plugin, e.g. the custom headers plugin. (Make sure you’re looking at a branch that’s appropriate to your version of OJS – for 3.1.2, that would be ojs-stable-3_1-2, for example.)

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

Thanks, I’ll take a look at it.

But there is no technical description on plugin development for OJS around?

Thanks, Tobias

Hi @twa,

There’s the old Technical Reference – however it’s very out of date. The basic principles of plugins still work as documented there, so perhaps a combination of the fundamentals written in the document and a bit of review of the plugins in the codebase (and commonly used plugins e.g. in the Plugin Gallery) will provide coverage for now. The very talented @NateWr is putting together a rewrite of our technical documentation to be launched on the Documentation Hub fairly soon.

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like