1

For a while the site editors have been using the wrong HTML headings (to get headings to look "right" instead of asking for the style sheet to be modified).

We have hundred of entries (in two specific channels) which we need to go over so headings that have been marked up as H3 are changed to H2, and headings marked up as H4 are changed to H3. The headings are in the body field as part of the main content for the entries.

Is there an automated way of doing this?

Thanks

2 Answers 2

8

Personally, this is where I'd just open Sequel Pro and run the database queries directly. But if you aren't use to working directly with the database tables or performing SQL queries directly, then ExpressionEngine provides a very simple and easy to use tool. But… PLEASE BACKUP YOUR DATABASE FIRST.

EE2 offers under the Tools Menu, the Search and Replace Tool. Search & Replace Tool

The type of find you are doing is relatively simple. So basically, you will open the tool: Place

Search For: <h2>
Replace With: <h3>

Then select which field that you want to do the find and replace on, from the database list

Search & Replace Options

Then perform the search. Now remember you need to do this for opening and closing tags, so don't forget the

Search For: </h2>
Replace With: </h3>

But just do this for each tag you need to replace. In fact, this tool, is perfect for this type of modifications. But it is powerful. So, please backup your database first, in case you select the wrong field, modify a template instead of a field, etc.

1
  • 1
    @GD Mac makes a good point, the order of your Search and Replace is important. You'd want to follow, the order in your original question. Convert current <h3>'s to <h2>s tags first, then convert <h4>'s to <h3>s. Commented Feb 13, 2013 at 15:32
3

Copy the table in the database first, and then use a SQL query to test things out and directly manipulate data in the table.

It should be fairly easy if only straight tags have been used
e.g. <h3>foobar</h3> and not `<h3 class="x">goobar</h3>

Be careful in which order you search-replace </h3><h3></h2><h2> because you don't want to first replace all h4 to h3 and then replace the just replaced h3.

Happy Query-ing

1
  • points go to @non_profit_tech
    – GDmac
    Commented Feb 13, 2013 at 11:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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