Unit 15. HTML and Dreamweaver (III)


Find and replace

 

Sometimes we want to search a web site for all pages with certain texts, labels, or parts of these elements. We might want to replace them because we need to work in these pages and don't remember which ones they were, or because we want to replace some labels with others.

Lets imagine an existing web site, where the majority of the pages have text that makes reference to the site's name from the start, for example, all the pages that start with DogsCats, and it is for sure that phrase isn't in any other part of the site apart from the start. Now lets imagine that a cat and a dog image have been created, and you want to replace the DogsCats text for the image in all the pages.

In this case it is not necessary to open all the pages that contain the text one by one, and neither to modify the pages to replace the text for the image one by one. To perform this task it is easier using the Find and replace tool.

You can open it through Edit menu, and then the Find and replace option, or by pressing Ctrl+F.

Through Find in you can specify whether it's going to be looked for in the actual file, in the entire site, or only in the selected site files (previously selected).

Through Search you can specify whether the text needs to be looked for (in the desgin window), or in the HTML code (font code).

Next to the Find option list, there is a text window in which you need to indicate the text or the code you want to look for.

In Replace you must specify the text or the code you want to replace the text or code found with.

The replacement can be made in various ways, but always through the right buttons. To search one by one for the files that contain the code or text needed, and replace when you need to use the buttons Find Next and Replace.

If you want to find all the files that contain the text or code, and replace all of them, you use the Find All and Replace All buttons.

When you use the Find Next option, a page with the coinciding text is opened, highlighting the font in the list near to the code line in which it is. This way we can decide on the changes we want one by one. When we are sure about the replacements we want we just need to click on Replace, and when we're not we just need to click on Find Next again.

When we use the Find All option, the Find and replace window closes and a new panel like the one to the right is opened. Here are all the files in which the text coincides with the searched for text or code.

By clicking on the button, the Find and replace is opened. From this window we can replace from the found files, one by one with Replace button, or directly replace all found files, by selecting the Replace All option.

In the panel, when any file has been replaced, this will appear again in the list near a green circle, which indicates that it has been previously replaced.

We can make errors when we search, or replace text or error codes. You have to be very careful when you use this tool, because it's not possible to undo the changes done to the closed files with the find and replace option.

In the previous example, the person wants to search for the DogCats text, and replace it with an image. In this particular case, what you want is to replace the text with an image, so in Find we couldn't choose the Text option, we would have to select Font code.

In Replace the complete HTML label would have to be specified to insert the image. In this case the label would be <img scr="images/logo_animals.gif">, knowing the image is called logo_animals.gif and is found inside the site in the images folder.

 

To practice the different aspects explained, you can perform the Step by step exercise on Finding and Replacing.

  Unit 15 exercises.

  Unit 15 evaluation test



  Ir a la página anterior Índice del curso  

Page. 15.3

Legal warning: Authorised on-line use only. It is not allowed the use of these courses in companies or private teaching centres.
© aulaClic. All rights reserved. Reproduction in any form whatsoever is prohibited.
November-2005.