The structure of the pages

Each page has its main content written in plain html. This is sandwiched between a short header, enclosed in php tags, and an even shorter footer, also a php fragment.

The header contains a list of variables which define the page and its position in the compendium. These are defined as php variables thus: $pagename = "aircon4";

In principle only the pagename is required, because all information about the page is held in a database. In practice all the database information is repeated in the page. This is done so that the site structure can be recreated from the files. A practical reason was that there were nearly 200 files that had to be transferred from the previous version of the compendium, which was plain html. A script was used to read the header of each modified file and generate a database.

After the variables are declared, the header calls another php script, which is the same file for all pages. This file is included in the page and executed by the server. It generates the navigation bars which appear at the top and bottom of the page when it is viewed in the browser.

A second php file is included at the bottom of the page. This searches the database for readers' comments on the page and formats them for the reader. It also makes a form for entering a new comment.

If the reader does choose to comment, the page is called again, with the reader's comment included as a 'post' message (this is a hidden message that is returned to the server when a viewer fills in a html form). This time, the file included at the top of the page takes over processing the comment, first presenting it to the viewer for checking and then accepting the confirmed entry and entering it in the database with a reference to the page name. The two php files which are included at top and bottom of each page cooperate to provide all the navigation, interaction and layout of the page. This makes for easy maintenance. Even if I abandon php in the future, it will be easy to rewrite just these two pages. The main body of the pages will need at most a few tag changes which can be made by a script traversing the entire directory structure.

The index page is an entirely different php program which takes information from the database and generates an index automatically, with a facility for zooming in on each section, showing abstracts of the pages. This index is rebuilt at every request, so new pages will automatically be shown in the index as soon as they are entered in the database. One could also program the index to mark pages which have had recent readers' comments.

This system entirely automates the navigation and indexing of the entire compendium, using a database to store and show reader comments and to generate automatic indexing and navigation menus.

Controlling the appearance of pages

The included file that makes the navigation also has a style sheet to control the appearance of the code in the bulk of the page. This means that the main body of text is in very simple html code. Only about five tags are used: paragraph, newline, image and two heading sizes. This makes the code very easy to edit and to extend. The style of the whole compendium can be changed by altering one file.

Downloading the whole structure for offline browsing

A student may wish to make a private copy of the entire site, to burn onto a cd for example. This can be done by any of the many web site downloading programs. There is one snag: the files all have the ending php. This will cause some browsers to render them as text files instead of html, showing the tags as text instead of interpreting them as layout instructions. Some web site downloaders can be instructed to change all php file names to html. The standard unix program wget will do this.

Licence

All material on this site may be downloaded, printed and distributed to others. I would prefer you not to copy pages to your own website, because this prevents further updating of the page: make a link instead. As for responsibility for the contents: I check that the material reflects scientific orthodoxy, but science is, by definition, never certain in its assertions, so this material cannot be read in the same spirit as a product specification.

Acknowledgements

My main debt is to the open source movement. This is one of the most encouraging developments of modern civilisation. It has generated a world spanning net of programmers who help each other, correct bugs and provide an enormous wealth of programming examples.

 

Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 License.