www.webdeveloper.com
Results 1 to 2 of 2

Thread: single css menu on multiple pages

  1. #1
    Join Date
    Apr 2012
    Posts
    7

    Cool single css menu on multiple pages

    i have just introduced myself to php, i am currently developing a website using frames, i have a css menu that has to appear on multiple pages,i have read there is a way of using php to connect the pages but it does not work, i really need help on this one.

  2. #2
    Join Date
    Jul 2009
    Location
    My house, sitting at the computer. Duh!
    Posts
    118
    Usually the way you'd accomplish this would be to put your menu in a separate file and function, and include that file where you need it. For example:

    Menu.php
    PHP Code:
    <?php
    function menu()
    {
        echo 
    '
            <ul>
                <li><a href="#">Link</a></li>
                <li><a href="#">Link</a></li>
                <li><a href="#">Link</a></li>
            </ul>'
    ;
    }
    index.php
    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
    <html>
        <head>
            <title>Some Page</title>
        </head>
        <body>';

    <?php
        
    require_once('Menu.php');
        
    menu();
    ?>

            <div id="body_content">
                <p>something else goes here</p>
            </div>
        </body>
    </html>
    This is an effective way to split up your website into multiple pieces, which is very useful when you want to add a button to your menu for instance. Then you only have to change it in one place, and it's updated on every page of your website.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles