Introduction

This page is prompted because some of the VAG seem interested in mechanisms.

The shop pages are driven by scripts; a mixture of PHP on the server and Javascript on the client. They have been built up over the years, not from a unified design, though the core seems quite sound as its stood expansion. Its all quite simple stuff; there isn't a database, just a static text file. The programs are not optimised for efficiency, and the commands called are fairly simple ones (because I'm not a programmer).

The main principle is one of data re-presentation. The page requested is drawn as it is requested by looking around the server at information stored and assembling what was requested. By building the page on request, the webmaster (me) hasn't got to keep a vast number of links maintained; they are only created when the page is requested. And, if I have new information to add, I just add the file, all the links take care of themselves !

Static Files and folders - the hidden bits

The main shop data file is a text file, containing one line of data per shop entry. The lines are divided into fields by tab characters. This file is created by saving part of the chief shopkeeper's Excel records as a text file (tab separated data). The product code numbers are the critical items in making everything work. The fields are: partnumber, description, price, unit of issue, comment (eg. NYA), shop(s). If the chief shopkeeper wants to change the product listings (add a product, change a price, etc), he uploads a new text file.

In addition to the shop data file, there is a file of "headings". This file contains the heading text, and any associated URL link, to be inserted into the shop listing before a particular product number.

There are two directories containing "useful" data. One contains images (gif, jpeg) of products, the other contains the "information" files about products. Each file (be it image or information) is named by product code.

The "information" files contain a table which has comment markers around it. That table contains the cross-referenced part details, the specific partnumbers being highlighted in the source table. The words and the parts have to be edited manually, but only the part numbers need to be entered when saving (plus links outside the shop area, such as to instruction sheets, or articles), the links to and from other files are built dynamically.

Dynamic Files - what the User Sees

Shop listings:

The shop listing pages are generated by a PHP script. The top of the page is static HTML (with PHP inserting the shop number and shop description text), as is the very bottom of the page. When the shop list table is reached, PHP takes over. This reads the main shop text file, line by line. If the line is not marked for that shop (eg. shop 1, shop 2, etc), it is excluded. Assuming the line is to be written, before processing the line, the headings file is checked, and if a heading is found for that line, it is written to the output. Then the line of the table is formatted, and providing there is a price for the item, a text-input box carrying the product code as its name is included in the line. The two directories containing images and information are checked to see if any file names match the product code. If they exist, the "info" and "camera" icons are added, with appropriate URLs. Those URLs call Javascript to display the relevant popup window.

Information Files:

The "information" popup windows are also built by a PHP script. The product number is passed to the script in the URL called as a parameter. The script reads that parameter (product number), then finds the static version of the "information" file matching the product number. The static version is displayed line by line, until the script finds the comment marker around the cross-reference table. It then reads the cross-reference table carefully, and when a partnumber is found, the PHP checks the directories to see if there are further information or image files (same method as shop listings). If further information or images are found, the icons are added, with URLs. At the end of the table, there is another comment marker, and the script then just displays the remainder of the static file.

Order to Print page:

This is PHP and Javascript, plus some CSS tricks for layout, and is called from a shop listing page.

The "order" area is written with PHP. The shop data text file is opened and read line by line. When a product code from the data file matches one submitted from the form (with quantity other than null), a line of "order" is written. The quantity is used to multiply the issue price, and the running total is increased. When the end of the shop data file is reached, the grand total (before post) is displayed.

The member's name and address is client side javascript, setting and reading cookies on the client machine. If the cookies are found, the values are pasted into the form. If the member decides to not save the values, then a session cookie is used which deletes itself when the browser is closed.

The popup for editing the name and address is controlled by the CSS, for its position and visibility. Also, the CSS has specific entries for print media, so the printed version comes out in a sensible font size on a reasonable amount of paper.

 

 

If anyone wants the source code to all of this, please ask.