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.
1. | 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: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. |
2. | 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 an108 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. |
3. | 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 basi107 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. |
4. | 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: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.<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.TipWhen 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. |