[Gllug] OT - simple HTML query

James McGuigan james-lists at worldfuturecouncil.org
Mon Aug 1 12:48:57 UTC 2005


Dylan wrote:
> Hi List,
> 
> I'm coding a small web site which has the ubiquitous left-side menu. I'm 
> doing my level best to avoid frames, tables and scripts. Since the 
> items in the menu are liable to be updated fairly often I'd ideally 
> like to keep a single copy of the HTML for the menu and simply have it 
> loaded or imported to the appropriate point in the page. Is this 
> possible? If so, how should I look at doing it?
> 
> Cheers
> Dylan

Have you considered using PHP (assuming its available on your webserver).

# index.htm
This is my menu:
<?php include('menu.htm'); ?>
An now for the rest of the page


# menu.htm
<ul>
<li>Menu Item 1</li>
<li>Menu Item 2</li>
<li>Menu Item 3</li>
</ul>


# .htaccess
AddType application/x-httpd-php .htm .html




My usual system for doing templates in PHP is to declare a set of variables in the 
called file (index.htm), such as  $title, $subtitle, $content  and so on, include the 
main template file, which is a HTML file with embedded php tags to print out those 
variables in the correct place. There are half a dozen other ways of doing it but 
this method works for me.

As for menus, I usually end up declaring them as a PHP array and have a small 
function/loop to print out the menu code (testing if the menu link points to the 
current page - giving it a different CSS style if so).

-- 
Rules are written for those who lack the ability to truly reason,
But for those who can, rules become nothing more than guidelines,
And live their lives governed not by rules but by reason.
      - James McGuigan

Earth Emergency - A Call to Action (www.earthemergency.org)
Sustainable Society Directory (www.sustainable-society.co.uk)
World Future Council Initiative (www.worldfuturecouncil.org)
Open co-op (http://open.coop)
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list