[OJS 3] custom metadata fields

Is it possible to add custom metadata fields to OJS 3 (for example, a Dublin Core “description” field)?

Or are there any plugins that can help with this?

If not, are there any instructions for doing so?

1 Like

Hi @kardeiz,

Adding custom metadata fields will take some custom coding. Overall I’m not hugely enthusiastic about providing blanket support for custom metadata fields – there are a lot of considerations around those fields’ interactions with e.g. the OAI interface and other metadata crosswalks. I’d suggest sticking within the standards, and coding those fields as first-class peers with the existing fields (complete with OAI crosswalks etc).

Note that the Dublin Core “description” field should already be receiving the article’s abstract.

Regards,
Alec Smecher
Public Knowledge Project Team

@asmecher, thanks for the reply. Sorry, “description” was a bad example—

I understand not wanting custom metadata built-in, but it would be really nice if there were some documentation about how to add them (or even better, an official plugin to do so). I would imagine adding custom fields would be a pretty common requirement (did OJS 2 allow custom fields?).

For my personal example, I don’t really care about OAI integration etc. It doesn’t even really need to be thought of as a Dublin Core field. I just need a textbox on the submission form (like the abstract box) that collects content and displays it on the article view page.

Digging into all the deeply nested templates is a very daunting task! Just trying to find out where a single variable in any given TPL is defined is an exhausting series of greps.

Hi @kardeiz,

Agreed, it’s not trivial to jump in and add a field. I think there are a couple of write-ups on OJS2 in the forum, but probably nothing yet for OJS3. Perhaps this would be a good chance to improve that situation :slight_smile:

Before I add some pointers – can I ask what the metadata you’d like to store is? Is it scholarly metadata, or some kind of instruction for during the workflow, or something else?

Regards,
Alec Smecher
Public Knowledge Project Team

@asmecher, cool, thanks!

Well, for my particular situation, this would be free text, an epigraph/notes provided by the author’s advisor (it’s a journal of undergraduate scholarship) that would be similar to but separate from the abstract. It wouldn’t affect any workflow logic. It could be in the initial submission workflow or not, as long as it was available in the Submission->Workflow->Production->Metadata section. TinyMCE integration would be nice but a simple textarea would be fine.

It would then just be displayed on the article view page. I could take it from there: article_details.tpl and related are pretty easy to follow.

Any help you could provide would be much appreciated. Thanks!

Hi @kardeiz,

When would this be added to the content? For example, upon acceptance (= entry into the production/publication part of the workflow)?

We’re looking at adding some generic content-management tools permitting better control over the published presentation of a submission, mostly for OMP, but also applicable to OJS. I’m wondering whether this would be a good candidate for an OJS requirement.

Regards,
Alec Smecher
Public Knowledge Project Team

Correct, in my use case this information would be provided only by an editor/admin (i.e. in the production phase). It wouldn’t be harmful to display the field/textarea it on submission, though, so whatever is easier or more generic would be fine for me.

Hi @kardeiz,

This seems like a good application of the kind of content management tools for publication that I mentioned above, rather than a metadata field like the DC set. Tagging @stranack, as he’s doing some related requirements work on OMP.

Regards,
Alec Smecher
Public Knowledge Project Team

@asmecher, thanks, that sounds like the best solution—

If you have any pointers, though, for doing this with the current Submission class, they would be much appreciated, as I need to implement this sooner rather than later…

Thanks!

Hi @kardeiz,

For a quicker fix, I’d suggest grepping through the code for a similar metadata field and following its pattern – e.g. “coverage”, since that term isn’t used elsewhere in a different way, and it doesn’t have many dependencies.

Regards,
Alec Smecher
Public Knowledge Project Team

@asmecher, thanks, that was helpful—

For anyone else looking to add custom metadata (in the most minimal kind of way—this doesn’t tie in with the translation system, DC, etc.), here is what you need to modify:

In lib/pkp/classes/submission/PKPSubmissionMetadataFormImplementation.inc.php:

  • In the initData function, add 'myField' => $submission->getData('myField', null) to the formData var
  • In readInputData, add 'myField' to the userVars var
  • In getLocaleFieldNames, add 'myField' to the array (not sure if this is necessary)

In lib/pkp/classes/submission/SubmissionDAO.inc.php: in getLocaleFieldNames, add 'myField' to the array

In lib/pkp/templates/submission/submissionMetadataFormTitleFields.tpl: append something like the following to the end of the template (here is a case where you might want to do some extra work to integrate with translations):

{fbvFormSection title="MyField" for="myField" required=false}
    {fbvElement type="textarea" multilingual=true name="myField" id="myField" value=$myField rich="extended" readonly=$readOnly}
{/fbvFormSection}

In plugins/themes/bootstrap3/templates/frontend/objects/article_details.tpl (or similar): add the following where desired:

{if $article->getLocalizedData('myField') }
    <div class="article-summary" id="myField">
        <h2>My Field</h2>
        <div class="article-myField">
             {$article->getLocalizedData('myField')|strip_unsafe_html|nl2br}
        </div>
    </div>
{/if}
3 Likes

Hi,

Connected to this thread I uploaded a plugin I worked on few weeks ago to github: GitHub - ajnyga/customMetadata

It is basically a plugin that enables you to create new custom metadata fields using the database. I am not going to use it myself, because I only need one custom metadata field and the same plugin that creates that field does a lot of different things as well. But if someone has been thinking of something similar I did above, then my plugin is probably worth checking first.

At the moment it only supports single locale and only a text input field, but the concept could be easily expanded to support multilingual fields and for example textarea as well. Also notice that if someone tries the plugin, it does not at the moment create the required database table.

Edit: the plugin is based on https://github.com/pkp/ojs/tree/master/plugins/generic/openAIRE

Edit2: and a filled database table would look something like this (note that the plugin does not use all the fields at the moment):

2 Likes

Hi @ajnyga,

I’ve installed your Custom Metadata Plugin and it worked for me. The context_id corresponds to the current Journal ID, is that right?

If I have more journals than one, should there be more rows in the table, some for each journal, is this the intention?

What if I want to use the Quicksubmit Plugin, shouldn’t this plugin also alter the Quicksubmit Plugin, which is probably not that easy?

Regards,
habib

Hi.

Disclaimer: it is not a ready-to-use plugin, just a concept that someone maybe can work on :slight_smile:

Yes, the context_id basically means the journal id.

You need a row for each journal. I was thinking that different journals may need different fields.

It is not hooked to the quicksubmit plugin. I am not sure if that is possible, if there is a hook available there? @bozana @asmecher?

Hi,

yes, I know it’s not ready-to-use, I was just asking.:slight_smile:
It would be possible just to quicksubmit an article and later in the workflow alter the metadata…

Yes, I am just washing my hands off any mess the plugin creates :smiley:

If the quicksubmit plugin has some sort of hook in metadata section then it should be fairly easy to implement it there. I think that this is a more general question: there are many other plugins that would benefit from being able to hook into quicksubmit.

Hi all,

QuickSubmit plugin does use already existing component, but I am not sure if that is enough – I will have to check, if all necessary hooks are there… I will then come back to you again…

Best,
Bozana

Hello Guys,

I have some articles without Abstract and the Abstract field is Mandatory during submission , How can i change this Mandatory field to normal ?

Thanks

I got it, Thanks much!