How to customize submission form?

Hi, I need delete Prefix and Subtitle from submission process, as these fields are optional I have no problems if I comment this lines (like below), but how can I keep this changes? I try to incorporate it in a Theme in template folder but I think Themes can’t modify the backend, so maybe I need to create a little plugin? Do you have any little example for this?

the modifications I made are in this file: submissionMetadataFormTitleFields.tpl commenting some lines whit * like this:

{* fbvFormSection for="title" title="common.prefix" inline="true" size=$fbvStyles.size.SMALL* }
	{* fbvElement label="common.prefixAndTitle.tip" type="text" multilingual=true name="prefix" id="prefix" value=$prefix readonly=$readOnly maxlength="32" *}
{* /fbvFormSection* }

With commented code is perfect to me, but if I can I keep this modified file (submissionMetadataFormTitleFields.tpl) in a plugin, and the backend read this modified file instead of the original one, this could work… but I don’t know if plugins work in this way, as a theme.

Hi @t4x0n,

Themes can modify the templates in the backend as well, though we often discourage this because we “break” compatibility in the backend more frequently than the frontend.

You should be able to override that template file by including a copy of it in your theme under /your-theme-name/templates/submission/submissionMetadataFormTitleFields.tpl.

I understand, my change is totally compatible… but I have try before this way to override and I try again now and is not possible, the form only change when I change the “official” file, not with the theme, and of course reload, clear cache from OJS and manually…

I am using in my machine for proofs OJS 3.1.1.0, maybe your introduce some changes in news version? do you remember some issue about change backend from a theme?

Update: I upgrade to 3.1.1-2 and is the same thing… not working. I am using defaultManuscript for made tests, so in this theme, I add a submission folder with submissionMetadataFormTitleFields.tpl file but I think is not reading this file

If you can share a zip file of your custom theme I’ll take a look and see if I can spot what’s going wrong.

no problem, as I say is just the manuscript with some very little changes: https://we.tl/BrZQMS9PDz

Ok, it looks like you’re getting caught by a template that can’t be overridden. I’ve filed an issue for this here:

In the meantime, I’d encourage you to search the code for any references to the template you’re trying to override with the core: prefix. Replace:

core:submission/submissionMetadataFormTitleFields.tpl

With:

submission/submissionMetadataFormTitleFields.tpl

That will allow your theme to override the template. I’ll try to ensure this gets taken care of for 3.2 but there’s a lot piling up there.

PRs are welcome from any observers who might be running up against this problem. :+1:

1 Like

Thank you! I found the problem, in lib/pkp/templates/submission/form/step3.tpl line 27

the first time I replace core:submission with submission in files out of lib/pkp and the forms disappear…

You can do it with a plugin without changing the core stuff. Here we go:

class HidePrefixAndSubtitlePlugin extends GenericPlugin {

	public function register($category, $path, $mainContextId = null) {
		if (parent::register($category, $path, $mainContextId)) {
			if ($this->getEnabled($mainContextId)) {
				HookRegistry::register('TemplateManager::fetch', array($this, 'templateManagerFetch'));
			}
			return true;
		}
		return false;
	}

	public function templateManagerFetch($hookName, $args) {
		$templateManager = $args[0];
		$template = $args[1];
		$cache_id = $args[2];
		$compile_id = $args[3];
		$result =& $args[4];

		if ($template == 'form/formSection.tpl' || $template == 'form/formArea.tpl') {
			$request = $this->getRequest();
			$router = $request->getRouter();

			// page request ?
			if (is_a($router, 'PageRouter')) {
				$page = $router->getRequestedPage($request);
				$op = $router->getRequestedOp($request);
				$a = $router->getRequestedArgs($request);

				// submission wizard page 3
				if ($page == "submission" && ($op == "step" || $op == "saveStep") && is_array($a) && count($a) > 0 && $a[0] == 3) {
					$id = $templateManager->get_template_vars('FBV_id');
					$title = $templateManager->get_template_vars('FBV_title');

					// fields from submissionMetadataFormTitleFields.tpl
					if ($title == "common.prefix")
						$hideField = true;
					else
					if ($title == "common.subtitle")
						$hideField = true;
					else
						$hideField = false;
						
					if ($hideField) {
						$result = null;
						return true;
					}
					
					return false;
				}
			}
		}
	}
}

thank you @j1shin, but I never made a plugin so, how does it? Do I need just one file with this code?

There are some articles about it, for example:

https://pkp.sfu.ca/wiki/index.php?title=Writing_a_Block_Plugin

1 Like

Customizing the submission form for metadata is one of the most frequent requests from our journal editors. Prefix, Subtitle, headings about “Dublin core” or “Additional Refinements” are unnecessary clutter for most submitting authors. Also, so ordering of the fields seems sometimes unusual (keywords are often found below abstracts). So we overwrite the standard submission template using a theme plugin (see screenshot). However, this requires some programming knowledge and overwriting backend templates is generally not recommended.
Thus, a more easy way to custumize the submission form would be a great enhancement for future OJS versions.

1 Like