homepage Welcome to WebmasterWorld Guest from 54.227.67.210
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderator: open

CSS Forum

    
Menu replication
okrobie




msg:4383352
 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

 

lucy24




msg:4383372
 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.

okrobie




msg:4383400
 8:07 am on Nov 4, 2011 (gmt 0)

Thanks Lucy24. I'll try a PHP forum.

tangor




msg:4383456
 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.

rocknbil




msg:4383542
 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.

okrobie




msg:4383680
 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!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved