I am new developing for OJS3 and I have been developing a Plugin to generate a download link for a PDF file.
In general, the plugin obtains the data from the DB of OJS3 to generate a letter of acceptance of an article for its publication (title, name of the authors, date of upload, date of modification of status, and status of the article). The plugin uses this information to generate a url encoded in json and encrypted in base 64 to pass the data as a parameter to another php program.
I had no problems getting the data, but I can not get OJS3 to register the plugin.
Here is the part of my code that register my plugin
function register($category, $path){
$success = parent::register($category, $path);
if(!Config::getVar(âgeneralâ, âinstalledâ) || defined(âRUNNING_UPGRADEâ)) return $success;
if($success && $this->getEnabled()){
HookRegistry::register(âTemplates::Article::Footer::PageFooterâ, array($this, âcallbackTemplateArticlePageFooterâ));
}
return $success;
}
Here is a link to the plugin
GitHub - htorres09/cartaPlugin: Plugin de Carta AceptaciĂłn para OJS3
Hi @htorres09,
The plugin probably isnât registered with the system. This happens when you do any of the followingâŠ
- Install the plugin through the plugin gallery or by uploading the .tar.gz package
- Run the upgrade script with the plugin in place
- Manually register the plugin with
lib/pkp/tools/installPluginVersion.php
When writing a fresh plugin from scratch, the last way is the best option. You can double-check that it worked by looking in the versions
table for an entry for the plugin.
Also ensure that your version.xml
has an <application>
element that matches the directory the plugin has been installed into. For plugins/generic/tinymce
, youâll see <application>tinymce</application>
, for example. If the names donât match, youâll have trouble with the registration function as you describe.
Regards,
Alec Smecher
Public Knowledge Project Team
1 Like
Yes, I try to uploading it in .tar.gz package. But I never saw the folder with the plugin appear in ~ojs3/plugins/generic
Then I copy of the plugin folder, change the ownerships of the files and granted permissions, and try to update via script
php tools/upgrade.php upgrade
When I tried to see it in the Dashboard, I got an error in the browser console
~/index.php/test/$$$call$$$/grid/settings/plugins/settings-plugin-grid/ fetch-grid? _ = 1516314756216
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
My error log:
PHP Fatal error: Call to a member function getCurrent() on null in /www/htdocs/ss/hector/ojs3/lib/pkp/classes/site/VersionDAO.inc.php on line 135, referer : ~index.php/test/management/settings/website
I will try to register manually as you suggest. Thanks for the help.
My Version.xml
<application>carta</application>
<type>plugins.generic</type>
<release>1.0.0.0</release>
<date>2018-01-16</date>
<lazy-load>1</lazy-load>
<sitewide>1</sitewide>
<class>CartaPlugin</class>
How can I register the plugin manually?
I read the source code of installPluginVersion.php
But how do I use it? Can you refer me to document to se how to register it manually?
Hi @htorres09,
To get its usage information, just run it:
$ php lib/pkp/tools/installPluginVersion.php
Install plugin version tool
Usage: lib/pkp/tools/installPluginVersion.php path/to/version.xml
Regards,
Alec Smecher
Public Knowledge Project Team
Thanks!
I will try it and see the result.
Didnât work.
It sends me an error, try to se definition of the function in OpenJournalSystems 3.0.0, but definition of getData() canât be seen.
PHP Fatal error: Call to a member function getProductType() on null in ~/ojs3/lib/pkp/tools/installPluginVersion.php on line 57
Hi @htorres09,
Are you actually using OJS 3.0.0? If so, Iâd strongly suggest upgrading.
Regards,
Alec Smecher
Public Knowledge Project Team
I had OJS 3.1.0-1, clean installation. Still got the error when I try to register via installPluginVersion.php
PHP Fatal error: Call to a member function getProductType() on null in ~/ojs3/lib/pkp/tools/installPluginVersion.php on line 57
Hi @htorres09,
What directory is the plugin in? (I.e. what is the full path to version.xml?)
Regards,
Alec Smecher
Public Knowledge Project Team
Hi @htorres09,
Hmm, that looks fine â what is the entry for the plugin in the versions
table?
Regards,
Alec Smecher
Public Knowledge Project Team
Thatâs part of the problem, I search in versions
table and donât find an entry; also didnât find an entry in plugin_settings
.
Hi @htorres09,
Do you have an entry in versions
where product
= ojs2
?
Regards,
Alec Smecher
Public Knowledge Project Team
Hi @htorres09,
Check your XML using an XML validator; I think youâre encountering a parsing problem.
Regards,
Alec Smecher
Public Knowledge Project Team
Thanks. I find the parsing problem with XML and now it is registered.
But as I try to enable the plugin in the dashboard found a weird behaivor, it added another instance of the plugin in the plugin list.
function register($category, $path){
$success = parent::register($category, $path);
if(!Config::getVar(âgeneralâ, âinstalledâ) || defined(âRUNNING_UPGRADEâ)) return $success;
if($success && $this->getEnabled()){
HookRegistry::register(âTemplates::Article::Footer::PageFooterâ, array($this, âcallbackTemplateArticlePageFooterâ)); }
return $success; }
My template path function
function getTemplatePath($inCore = false){ return parent::getTemplatePath($inCore) . âtemplates/â; }
Callback snippet
function callbackTemplateArticlePageFooter($hookName, $params){
$smarty =& $params[1];
$output =& $params[2];
âŠ
// Visualize
$url = â<a href=â . $query . ââ target=â_blankâ class='âpkp_button_primaryâ> Ver Carta de AceptaciĂłn â;
$smarty->assign(âqueryâ, $url);
$output .= $smarty->fetch($this->getTemplatePath() . âarticleFooter.tplâ);
return false;
}
Before enabling the plugin [TEST] Carta de AceptaciĂłn
After enabling the plugin
The articleFooter.tpl
<div id=âcartaPanelâ>
<h3>{translate key=âplugins.generic.carta.headerâ}</h3>
<ul>
{if !$query->wasEmpty()}
<li>{$query}</li>
{/if}
</ul>
</div>
But it doesnât display it.
Hi @htorres09,
Off the top of my head, the kind of template override youâre coding wonât be supported until OJS 3.1.1 is released. Iâd suggest using a hook, e.g. TemplateManager::display
, to override templates. There are examples of this in the plugins distributed with OJS.
Regards,
Alec Smecher
Public Knowledge Project Team
Thanks, I take the recommendedByAuthorPlugin as base.
I will look at the examples, thanks again.