[OJS 3] custom metadata fields

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!

Hi @bozana,

is there a hook into the quicksubmit plugin to add new metadata fields?

Hi all, sorry for the late response…

Yes, the QuickSubmit plugin uses the existing components and thus also the hook Templates::Submission::SubmissionMetadataForm::AdditionalMetadata.
You would however have to consider the QuickSubmitForm in your plugin, similar like OpenAIRE plugin is considering the SubmissionSubmitStep3Form in these code lines:

In general, the OpenAIRE plugin is a good example how to extend the article metadata with an additional filed – what hooks should be used and how to do that. Additionally to the code lines above s. also:

One code line is missing in the QuickSubmit plugin to enable saving of the additional field. S. this issue for that and the patch is coming: Enable QuickSubmit plugin to save additional article metadata · Issue #3121 · pkp/pkp-lib · GitHub

Best,
Bozana

1 Like

Hi bozana,
thank you! It works perfectly.
Best,
habib

I have installed custom meta data plugin.
Where will i add additional new fields.
OJS Version: 3.0.1

Can you please reply soon

Hi,
Reviving this thread, is there any new way to add a custom metadata field? I followed the steps suggested by @kardeiz and managed to add a custom field but its value is not stored anywhere; after submitting the form the custom field is empty. I’m using OJS 3.1.1.4.