Change Logo Image Setting

Hello there,

is there a way to change the logo option in the theme settings in OJS 3.2.1? The function modifyOptionsConfig seems to only be usable on the theme page, not the setup page (which is quite logical).
I would like to change the Label, because we are using the Logo in a slightly different way.

Kind regards
Daniela

Hi Daniela,

Yeah, as you’ve discovered the logo is not part of the theme options and so isn’t one of the fields configured by the theme. Instead, you can use a hook to modify the fields of any setup form. The one you want is FORM_APPEARANCE_SETUP. Something like this should work if you put it in your theme’s init method:

HookRegistry::register('Form::config::before', function($hookName, $form) {
	
	if (!defined('FORM_APPEARANCE_SETUP') || $form->id !== FORM_APPEARANCE_SETUP) {
		return;
	}

	// Look through $form->fields to find the field
	// with an id of pageHeaderLogoImage, and replace
	// the label with whatever you want. Something
	// like the following (untested)
	$form->fields = array_map(function($field) {
		if ($field->id === 'pageHeaderLogoImage') {
			$field->label = __('your.custom.locale.key');
		}
		return $field;
	}, $form->fields);

	return false;
});

Hi @NateWr,

thank you very miuch, I will try it out :slight_smile:

Kind regards
Daniela

1 Like

In case anyone else wants to do this: Insteadt of “if ($field->id === ‘pageHeaderLogoImage’)” it is “if ($field->name === ‘pageHeaderLogoImage’)”.

Otherwise it works fine :slight_smile:

Kind regards
Daniela