How can I override backend templates (OJS 3)?

Hi,
I need to change a little bit the template of the submission wizard. I found the file I need to change, I’ve tried to create a subfolder in my theme, but it does not work.

The file path is:
theme_name/templates/submission/submissionMetadataFormTitleFields.tpl

Where am I wrong?

Thanks,
Gregorio

1 Like

You can override backend templates as well: Customizing OJS(3.x) main admin interface - #4 by NateWr

However, I am not sure if that would work with the template you are talking about. What are you trying to accomplish?

Ok, thanks, but I can’t understand the file/folder structure to override backend templates.

Gregorio

Hmm, that template gets called with {include file="core:submission/submissionMetadataFormTitleFields.tpl"} from other templates. So maybe adding a template to the theme plugin folder is not getting registered for that reason. Having that core parameter will always call it from the pkp-lib? @NateWr?

Yes, I believe that is the case. You’ll probably need to override any template which calls it to remove the core: from the call. Those are submission/form/step3.tpl and controllers/modals/submissionMetadata/form/IssueEntrySubmissionReviewForm.tpl.

Hi @NateWr,

I am trying to override an Admin template:
I would like to add a new link after Site Settings with name ‘Others’
It 'is a copy of Hosted Journals link (list all the journals) and modify link ‘edit’ with others questions)
image

I created a new child-theme and structure:
Plugins/themes/default-child/templates/admin/

  • contextSettings.tpl
  • contexts.tpl
  • index.tpl
  • settings.tpl

image

The code in TestThemePlugin.nc.php is the same as in github (https://github.com/NateWr/default-child) change class name.

I read this topics:

It is not working,
How can I load my admin template without modify original?
If I created a new templates/admin in my Plugins/Theme
The context.tpl:

{**
 * templates/admin/journals.tpl
 *
 * Copyright (c) 2014-2018 Simon Fraser University
 * Copyright (c) 2003-2018 John Willinsky
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
 *
 * Display list of journals in site administration.
 *
 *}
{strip}
{assign var="pageTitle" value="journal.journals"}
{include file="common/header.tpl"}
{/strip}

<script type="text/javascript">
	// Initialise JS handler.
	$(function() {ldelim}
		$('#contexts').pkpHandler(
				'$.pkp.pages.admin.ContextsHandler');
	{rdelim});
</script>

<p>Hello World!!! </p>

<div class="pkp_page_content pkp_page_admin">
	<div id="contexts">
		{if $openWizardLinkAction}
			<div id="{$openWizardLinkAction->getId()}" class="pkp_linkActions inline">
				{include file="linkAction/linkAction.tpl" action=$openWizardLinkAction contextId="contexts" selfActivate=true}
			</div>
		{/if}
		{url|assign:journalsUrl router=$smarty.const.ROUTE_COMPONENT component="grid.admin.journal.JournalOneGridHandler" op="fetchGrid" escape=false}
		{load_url_in_div id="journalOneGridContainer" url=$journalsUrl}
	</div>

</div><!-- .pkp_page_content -->

{include file="common/footer.tpl"}

Do you know any doc with steps to modify o create a new templates ?

Regards.

1 Like

Hi @xavi,

What you’ve shared looks correct. Have you tried clearing the template cache under the Admin area?

If you can zip up your whole custom theme and send it to me, I’ll install it and see if I can spot what’s going wrong.

Oh, and one other thing: when on the admin page, you’re technically under the “site” area, not a specific journal. So you’ll need to make sure that you’ve activated your custom theme for the site, not just a journal.

I clean all the cache’s from frontend
I send you my plugin/theme.

Hi, I modify the file: ojs/templates/admin/index.tpl to include a new link

<li><a href="{url op="contex"}">More Options </a></li>
{call_hook name="Templates::Admin::Index::SiteManagement"}

I attached a photo.
ojs

I created a new ContextSettings.tpl to ContextTestSettings.tpl with code:
{fbvFormArea id=“journalSettings”}

		{fbvFormSection for="enabled" list=true}
			{if $enabled}{assign var="enabled" value="checked"}{/if}
			{fbvElement type="checkbox" id="enabled" checked=$enabled value="1" label="Optional checked"}
		{/fbvFormSection}

		<p><span class="formRequired">{translate key="common.requiredField"}</span></p>
		{fbvFormButtons id="journalSettingsFormSubmit" submitText="common.save"}
	{/fbvFormArea}

I copied contexts.tpl to contex.tpl
I modify contex.tpl


{if $openWizardLinkAction}

{include file=“linkAction/linkAction.tpl” action=$openWizardLinkAction contextId=“contexts” selfActivate=true}

{/if}

		{url|assign:journalsUrl router=$smarty.const.ROUTE_COMPONENT component="grid.admin.journal.JournalGridHandler" op="fetchGrid" escape=false}
		{load_url_in_div id="journalGridContainer" url=$journalsUrl}
	</div>

Do you know if I need to change any file more?

Is it working for you?

Yes, it is, my menu right now:
ojs

I would like to customize “More Options”

ojs2

I want the list of all journals and the opcion “Edit”
How can I duplicated “Hosted Journals”.

ojs3

Regards,
xavi.

Do you have a handler operation in place for the “More Options” link? Where is the code that loads that page?

Yes, I created a handler in /ojs/lib/pkp/pages/admin/AdminOneContextHandler.inc.php and modify the function name. contexts by mycontexts.
I have a new error:
This is my URL
http://localhost:800/ojs/index.php/index/user/authorizationDenied?message=user.authorization.roleBasedAccessDenied

My log:
"GET /ojs/index.php/index/user/authorizationDenied?message=user.authorization.roleBasedAccessDenied HTTP/1.1" 200 8838

Image with error:
ojs3

I am logged with my admin user.
I have the same error as OJS 3 - Authorization Denied
I installed in localhost with xampp
mysql --version
mysql Ver 14.14 Distrib 5.7.22, for Linux (x86_64) using EditLine wrapper

I cannot access to show the page with all the journals to edit like this:
ojs4

Regards.
xavi

I deleted all the files and created again without change names and now it’s working,
I have thisojs5

Now I need to delete menu “Remove” “settings Wizard” and “Users” and modify template to “Edit” button.

Regards,
xavi.

Hi xavi,

I’m glad you were able to get it working. I’m sorry but I don’t understand what you’re trying to accomplish. Can you describe in detail, from the end-user’s perspective, what you are trying to make happen? What do you want the user to see/do that isn’t currently there? That will help me understand the changes you’re making and I may be able to offer a good solution.

Hi @NateWr,
I have a different contextSettings in my theme/templates/admin
The original contextSettings.

ojs3_10

My new contextSettings are:

ojs5

I created a new Handler and Form

ojs/controllers/grid/admin/journal/form/JournalTestSiteSettingsForm.inc.php
ojs/controllers/grid/admin/journal/JournalTestGridHandler.inc.php

and

ojs/lib/pkp/controllers/grid/admin/context/form/ContextTestSiteSettingsForm.inc.php

I am not sure if I had the correct solution when I created a new Handler’s and SettingsForms.

I think I resolved my question.
Thanks a lot.
xavi.

Do you need to have a separate page? It might be easier to just add your extra fields to the existing form for editing a context.

Hi @NateWr, I created a custom admin page satisfactorily
I created a new handler, DAO and templates and it’s running OK
I would like to use this variables in my admin template,
I am not sure if I need to modify function initData() from lib/pkp/…/ ContextSiteSettingsForm.inc.php

Can you help me with this ?

Regards,
Xavi.

HI @xavi,

The Form classes include the following methods:

  • initData() - Use this to initialize data for a new form (ie - when the form is first loaded).
  • fetch() - Use this to pass data to the form’s template and load the template. It’s common to use readInputData() here to get any data that might have been submitted as part of the form.
  • execute() - Use this to validate the form and save changes to the database.