Skip to content

Make search overlay placeholder and description modifiable

Summary

The expanded search overlay has hardcoded phrases as can be seen in attachment. Add extra settings in the CERN theme settings so that users can add their own text text as placeholder and description (below input).

Implementation

Add 2 extra settings in the theme settings:

  • Search Placeholder
  • Search Description

The 2 settings should have as default values the current ones and they should be placed inside the settings about Header in the settings of the CERN theme

1) add the form fields

In order to make the form fields appear, you should add them in cernclean_form_system_theme_settings_alter in cernclean.theme

2) inject the variable in the template

This should be done in cernclean_preprocess_menu_main in cernclean.theme (check https://www.drupal.org/docs/theming-drupal/twig-in-drupal/twig-best-practices-preprocess-functions-and-templates)

3) change the template of the Search to include the terms you have defined

This should be done in menu--main.html.twig template. Replace the hardcoded phrases with the variables you injected in the previous step

Attachments

Screenshot_2020-03-30_at_09.58.12

Edited by Konstantinos Platis