0

How could I add a default text inside drupal's search box? I have done this with jquery but I need the text to be translated.

I know this can be done with the Custom Search module but it is a little overkill to add a module for such a small feature. Hopefully this can be achieved using my theme's preprocess function. Any ideas on how this can be done?

0

Use Drupal to communicate a translated string to Javascript:

drupal_add_js(array('my_string' => t('Default Text')), 'setting');

Then, have your jQuery read the value:

var str = Drupal.settings.my_string;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.