1

I want to change the default placeholder value of the search field from "Search..." to "XYZ" in Joomla (default search module). I have modified the default_form.php from the directory /joomla15/components/com_search/views/search/tmpl/ and even removed the following code but it makes no difference on the site:

<?php echo JText::_('COM_SEARCH_SEARCH_KEYWORD'); ?>

2

First of all, you should not edit the Joomla core files. If you need to change something, template overrides is the way to go. However, in this case it shouldn't be needed.

It looks like you're mixing up the search component (components/com_search) and the search module (modules/mod_search).

I assume you're using the module, and you can set the placeholder directly in the module settings. Go to Extensions -> Modules and locate your search module. Open the settings, and edit the field Box text to whatever you want the placeholder text to be.

Search module placeholder text

As you can see from the tooltip, the box will use a string from your language file if the box is left empty. This means you can also create a language override in order to change the text.

In that case the string you want to override is MOD_SEARCH_SEARCHBOX_TEXT.

0

To change the placeholder in any form use the following code:

$this->form->setFieldAttribute( 'name', 'hint', JText::_('KEY_OF_PLACEHOLDER') );

  • name : is the fieldname.
  • hint : placeholder. In joomla core files this is described by attribute hint.
  • key : is the key defined in your language file
  • i delete some php code from the above mention file but it not works .. can u please mention the file to write the code . – Shehryar Oct 28 '15 at 9:12
  • In default_form.php, there is already <input type="text" name="searchword" placeholder="<?php echo JText::_('COM_SEARCH_SEARCH_KEYWORD'); ?>" Did you modify the placeholder attribute? – user5491 Oct 28 '15 at 9:19
  • yes i remove the code and instead of this code just simple i give place holder value – Shehryar Oct 28 '15 at 9:25
  • you can just add a new value of COM_SEARCH_SEARCH_KEYWORD in backend. Go to language manager and create a new key. This will create a overrider of this key and this should work – user5491 Oct 28 '15 at 9:33

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.