OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Submission's Metadata: file types and required fields

Are you responsible for making OJS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
What to do if you have a technical problem with OJS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a development question, try the OJS Development subforum.

Submission's Metadata: file types and required fields

Postby Garant » Sat Oct 20, 2012 11:17 am

Hi!
I've two questions:
First:
I wonder how to modify author's new submission process in that way, that only certain file format could be uploaded by author?
In fact we need that author could submit only open office word and microsoft word file types during upload process.
Second question concerns step 3 (Entering the Submission's Metadata). I should able to make "Keywords" field as required field.
looking forward for any information!
Garant
 
Posts: 212
Joined: Wed May 30, 2012 8:53 am

Re: Submission's Metadata: file types and required fields

Postby jmacgreg » Tue Oct 23, 2012 9:41 pm

Hi Garant,

There is currently no way to restrict uploads to only specific file types, although it has been a requested feature in the past and may find its way into OJS in the future. One thing you can do though is modify the author's Submission Checklist to include instructions to only submit files of a certain type. You can modify the Submission Checklist (and even Author Guidelines, another place to add this information) from Journal Setup.

You can't make the Keywords field required without changing some code, unfortunately. If you have development experience, you may want to try searching the forum for "making field required" or "making field mandatory". You should find some tips that way.

Cheers,
James
jmacgreg
 
Posts: 4181
Joined: Tue Feb 14, 2006 10:50 am

Re: Submission's Metadata: file types and required fields

Postby Garant » Wed Oct 24, 2012 12:04 am

Hi, James!
Thank you for your reply! I understood.
I think - the best and quickest way to make fields required is to use JQuery.
Shall try it.
Garant
 
Posts: 212
Joined: Wed May 30, 2012 8:53 am

Re: Submission's Metadata: file types and required fields

Postby milligen » Thu Mar 06, 2014 4:51 am

There is a way, but it requires creating/modifying three files. Here are the steps, in case you're interested (in this example, only pdf files are allowed; see http://stackoverflow.com/questions/4234 ... ading-file for more information):

========= Save this javascript as file js/validate.js
Code: Select all
function Validate(oForm) {
    var _validFileExtensions = [".pdf"];
    var arrInputs = oForm.getElementsByTagName("input");
    for (var i = 0; i < arrInputs.length; i++) {
        var oInput = arrInputs[i];
        if (oInput.type == "file") {
            var sFileName = oInput.value;
            if (sFileName.length > 0) {
                var blnValid = false;
                for (var j = 0; j < _validFileExtensions.length; j++) {
                    var sCurExtension = _validFileExtensions[j];
                    if (sFileName.substr(sFileName.length - sCurExtension.length, sCurExtension.length).toLowerCase() == sCurExtension.toLowerCase()) {
                        blnValid = true;
                        break;
                    }
                }

                if (!blnValid) {
                    alert("Sorry, " + sFileName + " is invalid, allowed file types are: " + _validFileExtensions.join(", "));
                    return false;
                }
            }
        }
    }

    return true;
}

========== Insert this line in file templates/common/header.tpl
Following Line 38:
Code: Select all
<script type="text/javascript" src ="{$baseUrl}/js/validate.js"></script>

========== Modifty the <form> statement in templates/presenter/submit/step3.tpl
Line 14:
Code: Select all
<form ... onsubmit="return Validate(this);">
milligen
 
Posts: 4
Joined: Mon Nov 23, 2009 3:08 am

Re: Submission's Metadata: file types and required fields

Postby Garant » Thu Mar 06, 2014 5:02 am

Thanks!
Added to bookmark :)
Garant
 
Posts: 212
Joined: Wed May 30, 2012 8:53 am


Return to OJS Technical Support

Who is online

Users browsing this forum: Bing [Bot] and 4 guests