[OJS 3] custom metadata fields

@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.

I have tried all this modifications but there’s not any new metadata field on my submission form. There a way that I can achiev that? I need three field for the user to enter author name, university and degrees regardless they are registered or not.

I’m using OJS 3.1.0.1

1 Like

Hi @kardeiz
I followed your steps but it’s not working
I have the same problem, I am using ojs-3.1.1-4 stable and I tried to use Quicksubmit with a new implementation.

I opened other post:

I am interested on save some news fields on Quicksubmit import plugin and show this fields on Metadata

The new data is not in my database.

Regards,
xavi

1 Like

Hello, we are particularly interested in adding a custom metadata field in submission for POSTED CONTENT (asking authors to provide a DOI for a preprint).
If this is too complicated, would there be a way to manually add this information in the metadata on OJS (without having to manually editing the XML)?
Thanks.