| 3:37 am on Nov 4, 2011 (gmt 0)|
How do I keep from editing the menu on every page when I add a new page? There must be a clever way to do it:) It seems like there must be a way to edit the menu in just one place each time I add a new page. Thanks
| 4:49 am on Nov 4, 2011 (gmt 0)|
It can be done, but not in CSS. In general-- the exceptions won't help you here-- CSS is about what things look like, not what they say. That is, if you wanted every menu item to be surrounded by decorative doodahs like
*!+!* Menu Item *!+!*
you could do that in CSS. But adding entire slabs of text? Nope, that's a job for php or similar.
I feel your pain. One of these days I will have to bite the bullet and php-ize my own navigation.
| 8:07 am on Nov 4, 2011 (gmt 0)|
Thanks Lucy24. I'll try a PHP forum.
| 11:23 am on Nov 4, 2011 (gmt 0)|
PHP, PERL, SSI (easiest in my opinion)... there are a number of ways to accomplish... but you can't do it with CSS.
| 3:52 pm on Nov 4, 2011 (gmt 0)|
Since your question was answered via PHP in the PHP forum, if you don't want to do all your files in PHP, it's still easy with SSI's (Server Side Includes.) This "old school" technology is exactly what this is for, IMO there's no reason to involve a robust programming language (PHP) when SSI's will do - it's the right tool for the job.
Drop this into an .htaccess file in the root of your domain (Linux based, you can do it on Windows servers too but it's a lot different)
AddHandler server-parsed .html
Normally only .shtml files are parsed for SSI's, but that directive will parse .html files now too - which used to be a "greedy" thing to do but is rarely a problem with today's servers.
Now, anywhere you want the menu in plain old html files,
<!--#include virtual="/includes/navigation.txt" -->
The file can be anything - .txt., .html, doesn't matter.
If the file is in the the same directory as the including parent, you can use file instead of virtual - but virtual works for either case, and prevents a lot of dot-syntax ../../../ confusion. In the above example, it will start at the domain root, (leading "/") then look in the includes directory for the file navigation.txt.
There's even simple ways to set the "current page" as an active class.
| 9:43 pm on Nov 4, 2011 (gmt 0)|
Thanks RocknBil, I appreciate the advice, but by the time I heard from you, I had already implemented a PHP solution.
It was really easy. There is a sample on [w3schools.com ] that works like a charm. Thanks again!