Description of issue or problem I’m having:
I am making some style changes to the search.tpl page and need to implement some css classes on the dropdowns, however I cant find any documentation that describes how to add a class to the search field:
{html_select_date_a11y class="form-select" legend=$dateFromLegend prefix="dateFrom" time=$dateFrom start_year=$yearStart end_year=$yearEnd}
I tried just adding ‘class=“form-select”’ to the Smarty call but that doesn’t seem to work.
Is there another way to do add classes to the select box?
Steps I took leading up to the issue:
Making modifications to the select tags.
What I tried to resolve the issue:
Tried adding class=“form-select” to the Smarty call.
Also checked the forums for anything containing “html_select_date_a11y”, but no results. (Very little on Google either)
Application Version - e.g., OJS 3.1.2:
OJS 3.3.0.10
Additional information, such as screenshots and error log messages if applicable:
Thanks @Vitaliy
I’m not sure how to override the PKPTemplateManager functions so instead I’ve just added the Bootstrap styles for .form-select into the main css file: “#search_bar select”
This looks like it is working fine, although I don’t like the idea of having to duplicate the bootstrap styles.
Out if interest, where in the documentation would I find instructions on how to override PKPTemplateManager functions?
Documentation doesn’t include exact steps for that, only general information for developers about writing a plugin for OJS: https://docs.pkp.sfu.ca/dev/plugin-guide/en/
If using that as a template and through, e.g., this hook: pkp-lib/PKPTemplateManager.inc.php at b84a274742369313fe90b246487f672e3fcc5a10 · pkp/pkp-lib · GitHub, I think it’s possible. E.g.:
public function register($category, $path, $mainContextId = NULL) {
$success = parent::register($category, $path);
if ($success && $this->getEnabled()) {
HookRegistry::register('TemplateManager::display', array($this, 'doSomething'));
}
return $success;
}
public function doSomething($hookName, $args) {
$smarty = $args[0];
$smarty->unregisterPlugin('function', 'html_select_date_a11y');
$smarty->registerPlugin('function', 'html_select_date_a11y', function($params, $smarty) {
// Write your custom code here
});
return false;
}
Maybe it’s redundant to unregister plugin, I don’t know. But it gives a general sense. Docs about registering functions to Smarty: https://www.smarty.net/docs/en/api.register.plugin.tpl
Thanks @Vitaliy that’s very useful and I think I should be able to do something along those lines. I’ll accept this solution but will let you know how I get on.
Thanks again,
Ant