Making a plugin for OJS3

thanks @varshilmehta!

I am actually thinking a situation where you compare statistics for journals using the plugin and for journals not using the plugin. Our site theme has a “top articles of the week” stat in the site front page. At the moment it is counting the downloads, but that is of course not fair for journals with embedded HTML. I will have to find out what COUNTER says about this.

Do you know if there are some meta tags etc. for Google scholar to tell that the full text is on that page? I was looking that it would be maybe possible to add a feature to embedGalley that adds the XML references and list them for google scholar: Improve Google Scholar exposure with reference metatags!

Google was able to pick up. So dont worry about it. You can have a look on my site. Thanks

For start I wished to test plugin statically. It works only with several articles and with $smarty->get_template_vars('publishedArticle'). So the object PublishedArticle in most cases returns null. As for Article object there is a weird things to. For example, in 2 articles it returns articles with other id (and all the data). In several cases it not returns galleys.

So my main problem is that i don’t know how to retrieve JATS XML galley from article detail page in terms of PHP code in the plugin.

this is weird, because I have not encountered a similar problem with embedGalley. I mean the article object should be there always, because it is the article page. Do you have similar problems with embedGalley if you test it with the same articles?

Ok. I will test with embedGalley plugin. As far as I can see the problem is related to the hook, that is used. With Template::Article::Main hook all seems to be OK, but not with Footer hook.

Before doing more work, I want also to ask you the best way to expose article with PHP. My idea, after taking a look at the OJS code more precisely, is parse XML into POPO objects, assign data to the variables like here: https://github.com/Vitaliy-1/JATSParserPlugin/blob/master/JatsParserPlugin.inc.php#L156 and expose them through tpl file. In this case front-end will be generated according to smarty native way. What do you think about this approach?

And one more question is about order inside the hooks. Did you figure out how to change it, because in my case article statistics goes before the article main text?

The order inside hooks is a work in progress. Alec has something ready, but the work is not finished yet. I do not know the details.

I would definitely assign multiple variables of course depending on what you want to do with the layout.

Have tested embedGalley plugin. The problem occurs with several articles. From error log:
PHP Fatal error: Uncaught Error: Call to undefined method Article::getGalleys() in plugins\generic\embedGalley\EmbedGalleyPlugin.inc.php:147

Also Recommend Articles by Author plugin not always working. They both use Footer hook. I think the reason is in loading order. Maybe this plugins are loaded actually before the Article object is created? Is it possible?

Edit: seems to be a conflict between this plugins. After disabling the latter embedGalleys works fine.

I want completely change the front-end look of articles. Do it more PLOS- or elifesciences-like :slight_smile: Don’t know if it is better to do it with javascipt or change theme files. Also I am not aware how will work assigning ArrayObjects to smarty templates.

1 Like

That is weird, because I have one journal using the plugin without any problems and I think that a couple of others are using it as well.

I think it is the same problem as here: Article display page behaving differently - #14 by hannanhazari

Do you have the Recommend Articles by Author plugin enabled at the same time as embedGalley?

Do you happen to use defaultManuscript theme?

It feels as this is not so much connected to embedGalley but a bug in OJS?

About the themes, I have been looking at PLOS One as well, especially the tabbed view of their articles: http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0176009
I think that it would be a nice layout to have at least these tabs:

  • Article (abstract, main metadata, maybe full text)
  • How to cite (this takes a lot of room at the moment)
  • Authors (if author biographies available)
  • Statistics (if enabled, the problem is that at the moment the stats plugin is just hooked to a multipurpose hook. You would have to add a new hook and fork the stats plugin to hook it in the right place)
  • References (if available)

A have a work on progress theme that uses Jquery UI tabs (Tabs | jQuery UI).

Another way of making room to the abstract page would be using these Accordion | jQuery UI in the abstract page side bar.

Can you try changing this to return true;

I have a feeling that return false will prevent other plugins from using the same hook? @asmecher?

edit: note to self, I have that in embedGalley as well… But I recall reading (can not remember where) that return false would prevent other plugins from using the hook. I could be wrong here. I can not test that right now so if you can let me know, thanks!

Nope. Not helping. There is a need to note that, for example, with the last article embedGalley works on primary locale and not working with second locale. The same case if for recommend by author. But I don’t understand why is so, because for the 80% of articles all works fine.

We use own theme. It is much like default but with several bootstrap tweaks.

I have already used bootstrap for tabs and for small screen adaptation. Thinks, this is better option. You can see how the tabs and accordion (on small screens) look like in our articles: Psychological help in oncology practice | Psychosomatic Medicine and General Practice
Mostly I want to do the same, but on article detail page.

1 Like

I have a feeling that this would be a problem with any plugin using that hook and maybe also with the other hook you mentioned if other plugins use that. I will test embedGalley next week together with the other plugin. Maybe Alec with comment by then.

I have worked sightly with Smarty templates. That’s how working peace of code looks like:
https://github.com/Vitaliy-1/JATSParserPlugin/blob/master/templates/articleMainText.tpl

Here I have just iterated through journal article reference item object
@ajnyga, @asmecher, what do you thin about writing to Smarty templates this way? I mean is this OK to iterate through objects in template file? Or it is not OK in terms of speed or security? Don’t know Smarty so it’s better to hear yours point of view before writing actual code.
The final work will have presumably 500 lines of code. It would be broken into several template files for readability.

1 Like

I do not know about speed, but there are a lot of similar iterations in OJS.

Hi all,

On the issue of giving hook registrations various priorities, see this merged PR: pkp/pkp-lib#1815 Permit hooks to register with call priorities by asmecher · Pull Request #2318 · pkp/pkp-lib · GitHub

This has been merged for release with OJS 3.1.

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

Hi @asmecher,

After applying this patch how can I change priority?

Hi @Vitaliy,

After this is applied, when registering for the hook, you can (optionally) specify an additional parameter with priority:

HookRegistry::register('myHook', array($this, 'callback'), HOOK_SEQUENCE_NORMAL);

The HOOK_SEQUENCE_… constants are HOOK_SEQUENCE_CORE, HOOK_SEQUENCE_NORMAL, HOOK_SEQUENCE_LATE, and HOOK_SEQUENCE_LAST (in order of high to low priority).

Regards,
Alec Smecher
Public Knowledge Project Team

2 Likes