One of the most useful features in Dreamweaver is the Find and Replace dialog. Unlike most Find and Replace options included with word processing programs and the like, the Find and Replace dialog included with Dreamweaver allows you to search and then replace elements for an entire site, a current document, selected text, open documents, a specific folder, and even selected files within a site. Even better, you can use the Find and Replace dialog as a way to search for elements in source code, text in the Design or Code views, text within specific tags, or specific tags in general. Furthermore, the Find and Replace dialog doesn't require a page to be open before it's run; instead, you can open the dialog at any time while Dreamweaver is open. To open the dialog, choose Edit, Find and Replace or press Ctrl+F in Windows or Command+F on a Mac. The Find and Replace dialog opens, similar to Figure 14.9. Figure 14.9. Use the Find and Replace dialog to search for various types of elements.The basic Find and Replace dialog displays the following functionality:
As a demonstration of the Find and Replace dialog's functionality, let's perform a couple of searches, one basic and one advanced. To perform the basic search, follow these steps:
As you can see from Figure 14.11, the results of the search are displayed in the Search tab of the Results panel. The Matched Text column displays a short string of text, complete with the searched value underlined in red. In this example, remember that we searched for text in the local site. The companydirectory.htm page is the only page in our site that has the text Dorknozzle in the design. If you wanted to search for the text Dorknozzle in source code, you would get much broader results. Figure 14.11. The results of the search are displayed in the Search tab of the Results window.To make an edit to that page, simply double-click the row in the Result window. Doing this opens the page and highlights the matched text within the page. Of course, you can use the Replace and Replace All features to replace this string of text with something different. Because we just wanted to demonstrate the search functionality, we'll avoid the Replace and Replace All buttons. Now let's do a more advanced search. In this next example, we'll search for text contained in a specific tag using the Text (Advanced) option. To do this, follow these steps:
As you can see, the Find and Replace dialog is powerful. It becomes extremely powerful when searching for specific tags. Assume for a moment that you have a site that contains 1,000 pages. Also assume that each page uses different style sheets, each created by a different department. What if you were asked to replace all style sheet references on every page to match a single style sheet reference called styles.css? You'd be working for hours, opening every page and changing the style reference to point to styles.css. Using the Specific Tag option in the Find and Replace dialog, however, this effort would be minimal. Figure 14.12 shows what the Find and Replace dialog might look like to accomplish this task. Figure 14.12. Using the Specific Tag option, you can easily search for specific tags and attributes and then replace that tag or attribute with a custom value.As you can see from Figure 14.12, our search would involve locating the <link> tag with the attribute HRef with the attribute value set to anything. The query might look like this: <link href="<anyvalue"> That value would be set to styles.css or: <link href="styles.css"> The possibilities are endless. You'll quickly notice that dozens, if not hundreds, of possibilities exist using the many options available in the menus. |