Search and replace parameters

From Joomla! Documentation

Suppose you have a large number of articles, contacts, or other content type in your database and you realize that you want to change a parameter for all of these items. You could go through the back-end screen and change them one by one. If you have a lot of items, this could take a long time. Here is a trick you can use to quickly make global changes to parameters in Joomla!.

The basic idea is to export the desired table to a text format. Then you can use a text editor to do a global search/replace to change the parameter to the desired value. Then you import the table back into the database with the updated parameter.

Here is a specific example. Say you want to change the "Telephone" parameter from "Show" to "Hide" for all of your contacts. Here are the steps to do this.

  1. Using phpMyAdmin (or some other tool), make a backup of your Joomla! database (in case something goes horribly wrong!).
  2. In phpMyAdmin, open your Joomla! database. Contacts are stored in the "jos_contact_details" table. Navigate to the this table and press Browse to look at the rows of the table.
  3. Notice that only the first 3 parameters are listed. To see all of the parameters, you can press the "Print view (with full texts)" button and the entire list of parameters will show.
  4. Identify the name of the parameter and the value you want it to be. Most of the time, you can compare the values in the table to the values you see in the back-end screen to figure out what you want. If you are not sure, you can also look at the parameter XML file. For example, for Contacts, the file is "<Joomla! home>/administrator/components/com_contact/contact_items.xml". This file shows you the different possible values for each parameter. In our example, we want to change "show_telephone=1" to "show_telephone=0". This will set this parameter to "Hide" for every contact.
  5. Use the phpAdmin Export function to make an export of the file. Click on the "Save as file" checkbox in lower part of the screen to save to a file. Keep all of the defaults for file format.
  6. This will create a file called something like "jos_contact_details.sql". This is a text file that you can edit with any text editor. Make a backup copy of this file before you edit it, just in case. Then open the file and do a global search and replace to replace the parameters you want. For example, change "show_telephone=1" to "show_telephone=0". Be careful not to change anything else in the file.
  7. Back in phpMyAdmin, you need to clear the table so we can re-import it. To do this, just press the "Empty" button in the upper toolbar. You will get a warning message but be brave and say yes.
  8. Finally, press in Import button and import back in the file you changed.
  9. Check that your contacts are correct in Joomla!.

Most of the tables in Joomla! are easy to figure out. Here are some common ones:

  • Articles = jos_content
  • Categories = jos_categories
  • Sections = jos_sections
  • Users = jos_users