• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Chapter 3. Implementing Common Elements > Adjusting Legacy Server-Side Includes

Adjusting Legacy Server-Side Includes

You have learned how to build a properly formed SSI from scratch, but how do you adjust an existing improperly formed SSI? In this section, you'll learn the proper technique for modifying legacy SSIs so they will work correctly in both Dreamweaver and Contribute.

In the Files panel, expand the includes folder, if necessary, and open legacy.inc for editing by double-clicking it.

Dreamweaver opens this file in Code view because of the .inc extension. The page has two major sections, separated by the closing </head> and opening <body> tags:

<meta name="Keywords" content="Bounty General Hospital healing
 healthcare physician emergency room pediatrics maternity" />
<meta name="Description" content="Bounty General is your healthcare
 facility: We're here for you." />
<h3><img src="/images/logo_long.gif" width="427" height="63" /></h3>

Removing just the two page-structure tags isn't enough to clean up this SSI and make it Contribute-ready. Because this SSI has code for both the head and the body areas of the page, you need to split it into two separate SSIs to retain all the necessary functionality.

Start with the head section. Copy the two <meta> tags, being careful not to include the </head> code in the selection to be copied. Choose File > New to open the NewDocument dialog box. Select Basic Page and HTML from the left and right lists, respectively,and click Create to make the new file. After the file opens, switch to Code view, select allthe existing code, and press Delete. Press Ctrl+V (Command+V) to paste the copied <meta> tags within the new blank page. Select File > Save and save the new page in the includes folder as legacy_head.inc.

Each of the SSI sections needs to be isolated so that each can be added to pages separately in its own section.

Return to the original legacy.inc file and select the section of the code below the opening <body> tag; press Ctrl+C (Command+C). Again, choose File > New to open the New Document dialog box and create another basic HTML page. When this new file opens, remove the existing code. Then paste in the Clipboard contents with Ctrl+V (Command+V). Select File > Save, and save the new page in the includes folder as legacy_body.inc.

With the legacy.inc file divided into two new SSIs, the remaining task is to locate any files containing the reference to the original include and then substitute the two new SSIs.

Select Edit > Find and Replace. When the Find and Replace dialog box opens, set “Find in” to Entire Current Local Site and make sure that Search is set to Source Code. In the Find area, enter this code fragment:

/includes/legacy.inc" -->

Choose Find All to locate all the instances of the original SSI. A code fragment is used in this case rather than the entire SSI code, to make sure that any references to this particular file in an include are found.

All the found instances are displayed in the Results panel.

In some very structured sites (where you know for sure that this include is always followed by the closing </head> and opening <body> tags), it might be possible to do a global search and replace. However, because structural tags are involved, it's probably a better idea to adjust the files one at a time.

In the Results panel, double-click the first entry in the list to open the specified file. While the SSI code is still highlighted, press Delete to remove it. Position the cursor in the head region of the code and choose Script: Server Side Include from the HTML category of the Insert bar. Make sure that the Relative To option is set to Site Root, and select the legacy_head.inc file from the includes folder. Move your cursor immediately following the <body> tag and insert another SSI, this time selecting the legacy_body.inc file. Repeatthis step for every entry in the Results panel.

In this exercise, it was assumed that all the SSIs had the same code. In a true legacy site of any size, you'll never know exactly how the code is presented, and it's a good idea to search using the broadest criteria. In this example, to make sure that all references to this SSI were located, the Search field in the Find and Replace dialog box should contain just the filename legacy.inc.


When publishing modified files, you should opt to incorporate the dependent files to ensure that the SSI files are placed on the remote site along with the encompassing page.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint