2 replies [Last post]
massive3215
Offline
Enthusiast
Last seen: 14 years 7 weeks ago
Joined: 2004-04-16
Posts: 81
Points: 0

I wanted to see if anyone has any suggestions as far as best practices for menu maintenance on large sites? I deal with CSS and have used some ASP includes in the past for menus. When dealing with large sites I'm wondering if there is a better way to maintain complex menus if the client wants changes rather than going in and updating all the pages by hand. Maybe through PHP, or some other programming language. For example if my menu looks like the following below with the selected page having a class that highlights it so the user knows what page they are on. Thanks!

  • Home
  • Item 1
    • Sub Menu Item 1
    • Sub Menu Item 2
  • Item 2
  • Item 3

Tags:
thepineapplehead
thepineapplehead's picture
Offline
Moderator
Last seen: 16 weeks 2 hours ago
Timezone: GMT+1
Joined: 2004-06-30
Posts: 9683
Points: 819

PHP or ASP includes so you

PHP or ASP includes so you have one file, say menu.inc, that you update once and it gets included on every page.

There is a javascript (I think) trick that will automatically add the selected class to the correct link, as well Wink

Verschwindende wrote:
  • CSS doesn't make pies

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 7 years 31 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

You have sort of answered

You have sort of answered your own question in mentioning PHP. if you have that available then build your menu in PHP using an array and loop over it to produce your html links and set active classes if required that can be styled using CSS and then just require or include that file in all pags that need a menu.

A search on php menus should throw up links explaining in greater detail

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me