|Page 1 Page 2 Page 3 Home|
Content Page 1Welcome to the multi menu example. This web page is not really fancy but it shows what HTMLCombine can do for you.
This sample consists of three pages content1.html, content2.html and content3.html. You can go to each one by using any of the four menus around the page. These pages were created from the following source files:
src/menu1.html - The menu at the top and bottom
src/menu2.html - The menu on the left and right
src/info.html - The text you are reading
src/build.bsh - CPMake build file to put it all together
Click on each file and then select view source to see the file with the included HTMLCombine tags.
Start by looking at the source for the template.html file. An important thing to note here is that this template can look any way you want. In this example the template is a simple table that places the menus around the screen.
Now look at the <htmlcombine> tags. There are seven of them. All of these tags are removed by HTMLCombine and either left blank or replaced by the appropriate values. Take a look at the first one:
<replace><span style="font-weight: bold;">$1</span></replace>
This is a simple rule for HTMLCombine to follow when inserting a menu into the template. It is basically a modified regular expression where %target% is replaced by the the name of the output html file. Then HTMLCombine goes through the menu file doing a search and replace. This lets you modify the menu so that the links pointing to the current page can be altered. In this example they no longer are links but are just bolded.
The next tag is this one where the title should be
These tags become place holders for values that will be defined in one of the included content pages. Look at the source for one of the content pages and at the top you will see
<htmlcombine name="title">Content Page 3</htmlcombine>
HTMLCombine replaces the first tag in the template with the value from the second tag that is in the content. You can also use this same technique for adding special style sheet definitions or java script.
Now lets look at the tags to insert the menus. The all have the following form
<htmlcombine type="menu" src="menu1.html"/>
The type="menu" tells HTMLCombine to perform the menumatch search and replace on the content. The src attribute tells it where to get the content for this tag. As you can see from this example the same source can be inserted at multiple locations in the template. This is nice because sometimes you want to put a menu at the top and the bottom of the page for ease of navigation. With HTMLCombine the menu code now lives on one document that is easy to alter and update.
OK two tags left:
The default type for an htmlcombine tag is "content". That just means it is just a place holder and HTMLCombine is to put the contents there without any changes. The second tag is a link to the text you are reading and it works the same as the tags used to put the menus in. The first tag is like the one to put the tittle on the page. It is just a placeholder. To find out where the value comes from we have to look at the build file
Lines 27 and 28 from build.bsh:
27: htmlCombine = new HTMLCombine("template.html", f.getName());
28: htmlCombine.parseContentFile("content", prereqs);
Line 27 is where we create the HTMLCombine object. The first param is the template file to use and the second is the name of the target file. The second param is what is used in the menumatch search and replace.
Line 28 is where we define what the "content" tags value will be. Here we are setting it to the value of one of the content files.
In a real world situation the content files would contain all of the information and the template would only have a copy right notice or maybe some logo that you want to show up on every page.
|Page 1 Page 2 Page 3 Home|