How to make global menu?

Discussion in 'HTML & Website Design' started by irule272, May 21, 2009.

  1. #1
    Hello my websites has 100+ html files and everytime I will modify my menu I need to do it manually.

    Is there a way to make it global so that I will just modify it in one file?

    Thanks
     
    irule272, May 21, 2009 IP
  2. Kerosene

    Kerosene Alpha & Omega™ Staff

    Messages:
    11,366
    Likes Received:
    575
    Best Answers:
    4
    Trophy Points:
    385
    #2
    You can use php to 'include' your menu in every file.

    Where the menu would normally be on every page you just put:
    <?php include 'menu.php'; ?>

    And then create a menu.php file with the html for your menu in it. Then when you need to change your menu, you only need to change 1 file (menu.php).
    More reading...

    Since all your files are already .html, you'll need to rename them all to .php, and then look into using htaccess to make sure you don't lose your spidered links. This is much easier than it sounds - the nerds in the Apache forum on DP are very helpful :)

    Or you can try getting php to work in html files.

    More reading:
    http://forums.digitalpoint.com/showthread.php?t=5801
     
    Kerosene, May 21, 2009 IP
    larssonk22 likes this.
  3. pmp123

    pmp123 Member

    Messages:
    219
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #3
    Yes PHP includes in the easiest way OR use dreamweaver templates (dwt). This will make it easy for you to make changes in menu.
     
    pmp123, May 21, 2009 IP
  4. irule272

    irule272 Well-Known Member

    Messages:
    1,153
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    155
    #4
    Ok thanks Kerosene I'll try it now!
     
    irule272, May 21, 2009 IP
  5. irule272

    irule272 Well-Known Member

    Messages:
    1,153
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    155
    #5
    Kerosene seems like it's not working here. I just wondering if I the code will work on a local machine or just on the host server?


    Here's the code that I made


    menu.php

    <body>
    <a href='Home.php'>Home</a> -
    <a href='AboutUs.php'>About Us</a> -
    <a href="links.php">Links</a> -
    <a href='Contact.php'>Contact Us</a> <br />
    </body>
    </html>


    index.php


    <body>
    Index
    <br/>
    <?php include("menu.php"); ?>
    </body>
    </html>


    What do you think is the problem?
     
    irule272, May 21, 2009 IP
  6. WarMarks

    WarMarks Peon

    Messages:
    125
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Buddy, php will work only if you run it own a php powered machine...
    I suggest you upload these files to your hosting server and they try to access the pages.

    Or if you need a local solution...go install WAMP from here
    http://www.wampserver.com/en/download.php

    And install it to your machine...
    After restart.... put your html/php files in www directory inside the WAMP
    folder ....

    Fire your browers and access those files or folder throught http://localhost

    Regards,
    Warren
     
    WarMarks, May 21, 2009 IP
  7. irule272

    irule272 Well-Known Member

    Messages:
    1,153
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    155
    #7
    Thanks WarMarks. Sorry I'm new in web design and coding I'll try that! thanks!
     
    irule272, May 21, 2009 IP
  8. irule272

    irule272 Well-Known Member

    Messages:
    1,153
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    155
    #8
    WarMarks on what specific folder on the WAMP folder do I need to put the html/php files? Hmm can you be more specific on the "http://localhost" I cant find the exact directory. Thanks
     
    irule272, May 21, 2009 IP
  9. irule272

    irule272 Well-Known Member

    Messages:
    1,153
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    155
    #9
    oops sorry its working now! Repped to Kerosene and WarMarks Thanks again!
     
    irule272, May 21, 2009 IP