|
25 Years of Programming
An open source source for C, C++, OWL, BASIC, MDB, XLS, DOT, and more... |
Home Projects Sitemap Search Blog Forum+Chat About Us Privacy Terms of Use Feedback FAQ Images Services Payments Humor Music |
Convert FrontPage 2003 webbot shared borders, link bars, and themes to include pages, HTML link bars, and CSS - Part 2
IntroductionThe reasons these conversions can be worth doing are given in the Introduction for this series, which is in Part 1 (see above). What is a FrontPage navigation webbot?Like the other FrontPage webbots, the Navigation Webbot (as seen in Code View) is merely an HTML comment in the
code Also like the other FrontPage webbots, the Properties dialog you see in Design View is just a "user-friendly" interface to the webbot text you saw in Code View. There's no hidden magic. The Properties translate directly to text, and vice versa. Also like the other FrontPage webbots, the end result of a navbar webbot is HTML (plus, in this case, some JavaScript) in the code of a web page. FrontPage creates the HTML as it saves the file, similar to what is described at How Webbot Includes Work: the original webbot tag is converted to two webbot tags, with the generated HTML code inserted between them. You can see the HTML when you open the page in Notepad instead of in FrontPage. Advantages of converting navbars to plain HTML
Disadvantages of converting navbars to plain HTML
To close with a technical point, as you might have inferred, webbot navbars actually are already HTML. In "webbot" form, they are HTML comments. In "saved" form, they are HTML+JavaScript. When you "convert" them, what you're really doing is taking control of the code (and the image files) away from FrontPage. How to convert webbot navbars to HTML1) Create new folders in your websiteFor each page that participates in a navigation link bar, FrontPage creates a set of button images that it stores in folders named _derived. Search through your entire site. In every directory where there is a _derived folder, create your own folder named derived, without the underscore, and (in the FrontPage Folder List pane) copy all files from _derived to derived. You might wind up using only a few of these image files, but it's best to copy them all in case you want to use others later. If FrontPage ever deletes the _derived folders or the files in them, you'll still have them in your derived folders. If you can't find the _derived folders:
2) Identify all the pages where you use webbot navbarsThe likely locations are: a) On individual pages where you have created custom link bars. These will be relatively straightforward to convert, using the procedure in Section 3) below. If you have any of these, do them first so you become familiar with the procedure and with the HTML code. b) In "included content" files such as top, bottom, left, and right borders. The conversion procedure for these is more complicated. The reason is that navigation webbots refer to the site's Navigation structure to determine which pages are global, which pages are siblings of each other, and which pages are children of other pages. When the webbot is in an include file, none of that information is applicable to the include file itself because it doesn't participate in the site's navigation structure. Therefore, when the include file is saved, no HTML navbar code is generated, and there is no code to copy as described in the steps of Section 3) below. When a page that "includes the included file" is saved, the navigation webbots do generate and insert HTML navbar code, but the code generated is specifically calculated based on that page's place in the Navigation structure. If you use an include file to include the same webbot (for our example, we'll assume it is an s-type="children" webbot) into 1000 different pages, you will wind up with 1000 different navbars, a different one on every page, because every page has different children. Therefore, the bad news is that you cannot craft a single block of HTML navbar code and reuse it in all 1000 pages. Each page must have its own code. The good news is that each page does already have its own unique navbar code, calculated by FrontPage, in it. You can view it by opening the page (not the border file or include file) in Notepad.
If you need to convert webbot navigation bars that are within borders or include files, read Section 3) for its background information, but then use the method in Section 4). 3) Do these steps for each webbot navigation bar
I consider it desirable to remove the JavaScript bloat that FP puts in navbar code. All it does is change the color of a button when the mouse pointer hovers over it. Here is some FrontPage navbar code from my site, with the parts I removed in red: This was the original webbot code: <!--webbot bot="Navigation" s-orientation="horizontal" s-rendering="graphics" s-type="siblings" b-include-home="FALSE" b-include-up="FALSE" --> Replacing that line with the code copied from Notepad resulted in this (after reformatting it): <script
language="JavaScript"><!-- After removing all the code in red, the end result is navbar code that looks like this. This is a navbar with two buttons: <a href="rectext02.htm"> A lot better, don't you think? Here is one section with its parts color coded: <a href="rectext02.htm"> The pair of <a></a> tags defines an "anchor" (hyperlink). Its href property tells you what page the link will go to when it is clicked. Whatever is between <a> and </a> is the object the user clicks on to follow the hyperlink. In this case, it is the image defined by the <img> tag. The image's src= property is the filename of the image. You can see that I changed it to point to the image in the derived folder rather than _derived. This can easily be converted to a plain text navbar. Without the clutter of the code for the image, you can see that it is fairly simple: <a href="rectext02.htm">Go to LP Records Listing, Page 2</a>
All I did was remove the <img> tags and replace them with text between <a> and </a>. Now the text is the object that the user clicks on to follow the hyperlinks. This is the essence of a text navbar. This is a navbar with two text links. As an exercise, can you see how I would add another link to this bar, one that goes to rectext04.htm? I would copy the second line, paste it underneath, and in two places change 3 to 4. That's all! Simply put, a navigation link is just a plain old fashioned hyperlink, and a navigation "bar", whether it is text or graphical, is several of those hyperlinks next to each other or one above the other. 4) Converting navigation bars inside "include" filesEach page that gets its navbar from an include file does already have its navbar code embedded in it, when it is viewed with Notepad. The problem is that whenever the file is opened and saved, FrontPage reprocesses the include file and recalculates the navbars inside it. We must stop it from doing that, but we must do it in a way that preserves the webbot navbar code which FrontPage has already generated for us. The way to do that is to delete all the webbot tags which surround the text we want to keep, in every file. This can be done with Find and Replace using regular expressions based on the ones from Walkthrough of a Regular Expressions Find and Replace.
a) Demonstration how the method works, on ONE page, manuallyIncluded content webbot tags look like this when they are viewed with Notepad. It is these tags we are going to remove: <!--webbot bot="Include" U-Include="includes/top.htm" TAG="BODY" startspan -->
<!--webbot bot="Include" i-checksum="28482" endspan --> To delete these tags:
To complete the conversion, do that procedure on every page. On a small site, you can do it manually without too much trouble. On a large site, you need an automated method, but it introduces complications that make it necessary to use regular expressions for the Find and Replace. b) Remove a pair of webbot tags from ALL pages in a website, automatedMake a complete backup copy of your site before you do this because if it doesn't work, it will make a mess of the site and you will have to revert to the backup. You cannot "undo" the steps below. Do the following procedure once for every include file that you need to replace. For example, if you have a top.htm border file with a Navigation webbot in it, and also a left.htm border file with a Navigation webbot in it, do the procedure twice, once for each file.
Copy the text below so you can paste it into the Find what box. However, you need to customize it first:
<!--webbot bot="Include" U-Include="(\.\./)*includes/top\.htm" TAG="BODY" startspan -->{.@\n(.@\n)@(.@)}<!--webbot bot="Include" i-checksum="[0-9]@" endspan --> In the Replace with box, put just two characters: \1 This Find and Replace will locate the opening and closing webbot tags, save the text that is between them, strip off the webbot tags, and paste the saved text back into the page. If you have thousands of pages, each Find and Replace may take several minutes. When it finishes, it might turn out useful for later reference if you make note of how many replace operations were done. Change all _derived/ folder references to derived/ The next step is to find all locations where the source code refers to a _derived/ folder and change it to point to derived/ instead, as discussed earlier in Section 3). The most straightforward way to do this is with a global Find and Replace, searching for every instance of _derived/ in the source code and changing it to derived/. First determine whether any page of your site uses the text _derived/ for any purpose other than as a path to a navbar image. It probably doesn't, but try to be sure. If you are able to use a simple Find and Replace for this operation, here are the settings:
If you are not able to use the one simple _derived/derived replacement, you'll need to do a series of Find and Replace, using more specific search terms such as full or partial names of individual files whose paths start with _derived/, etc., so you only replace the correct instances of _derived/ and leave the others alone. When finished, test some pages to make sure they all have their navbars and have survived the procedure without getting corrupted. Now that you are done, each individual page of your site contains embedded in it the full code that it previously got from the external include file. Therefore, the external include file is no longer being used for anything. It is now ok to delete it unless the next paragraph applies to you. As a side-effect of this conversion, your pages now also contain all the other text (non-webbot code) that it previously got from the external include file. If you would prefer to put that code back into a shared include file, you can do that with a new set of global Find and Replace operations. How to do that is beyond the scope of this article. You might also be able to put some of the HTML navbar code back into include files. If you can find groups of pages whose navbar code is exactly identical, you can pull that code out into a common include file. Webbot tipsA) How to "trick" FrontPage into creating navbar images for youOn my site, I wanted new navbar buttons for pages that didn't already have buttons.
B) How to "trick" other FrontPage webbots into writing HTML for youI don't mind FrontPage's automated methods. I just don't like being locked into them. If I ever need a custom link bar... Well, the end result above turned out to be so simple, I can now create it easily. But if I couldn't figure out how, I'd go ahead and create a <webbot> link bar, then do the procedure above to convert it. That's my plan for any webbot method for which I don't know the corresponding HTML: let the webbot do it, then get rid of the webbot and keep the HTML it created. Additional note 1/2/2008: Last week, I changed the top site-wide navbars from button links to plain text links. It saves about 15KB per page, creates fewer server requests per page load, and I like it better. There are still some examples of manually created button navbars on the pages that start at LP collection plain text database / tips for searching for classical music on the internet. Use View Source to see the code used. The next article is Part 3 - Converting a FrontPage theme to CSS Need help? Ask in the forum. |
|
|
|
|
|