1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to I create one menu for all pages?

Discussion in 'HTML & Website Design' started by Ronen1m, Feb 20, 2013.

  1. #1
    Hi all,

    I have a small website... I made it.
    www.RonenMymon.com
    It is simple and answers my needs for now...

    Here is my problem...
    I have the menu bar. and it is in EVERY page.
    Means, when I have something to change/add, I need to change/add in EVERY page... And I have a lot of pages....

    Is there a better way (I'm sure there is) and simple to create one menu bar instance for all pages? (just to update once and all pages will take from same place).
    How do I do that??

    And of course if you have any remarks or suggestions about my website.. I'll be happy to hear!

    Thanks!!
    Ronen
    SEMrush
     
    Ronen1m, Feb 20, 2013 IP
    SEMrush
  2. scottlpool2003

    scottlpool2003 Well-Known Member

    Messages:
    1,709
    Likes Received:
    48
    Best Answers:
    9
    Trophy Points:
    150
    #2
    <?php include "includes/menu.php";?>

    This will call 1 menu to as many pages as you put the above code into. I use this for other things too like header/footer etc.
     
    scottlpool2003, Feb 21, 2013 IP
  3. Ronen1m

    Ronen1m Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #3
    Hi!
    Thanks for your reply!
    What should be the index file type? shtml/html/htm?
    It doesn't seem to work for me....
     
    Ronen1m, Feb 21, 2013 IP
  4. jacksarlo

    jacksarlo Well-Known Member

    Messages:
    154
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    100
    #4
    I use this on my website, I have this:
    <?php include "menu.php";?>

    If you use like Scott said you have to upload the php file in the includes folder more tricky.

    Step one:
    Put above code where you want menu to appear (In Komposer Insert << Php). The page you put the code on can be .html or .htm (both are the same), I don't know if it works with .shtml You have to put the code on all webpages you want menu to appear but then just update the menu.php file to update them all.
    Step two:
    I use Komposer to create the website, just create your menu first in a new blank page, and then click Save As menu.php or whatever name you want. I have footer.php, leftmenu.php etc.

    Step three:
    Upload this menu.php file, as well as the html page/s with the php code in them to your website in the root folder (where index.html is).

    Optional step:
    I suggest before uploaded menu.php file to open the file using notepad and remove the stuff in <head> </head> just leave the contents in <body> </body> and remove html doctrine or whatever stuff above <head> is there. You do this to keep code clean and must be done each time you edit the php file.

    I personally took a course in html and css free online at: http://www.w3schools.com/html/default.asp
    This stuff sucks I know it's tricky.

    If you can't do this then hire a programmer for say $15 to set this up for you, guru.com (tell him also how he did it).
     
    Last edited: Feb 21, 2013
    jacksarlo, Feb 21, 2013 IP
  5. scottlpool2003

    scottlpool2003 Well-Known Member

    Messages:
    1,709
    Likes Received:
    48
    Best Answers:
    9
    Trophy Points:
    150
    #5
    The index file needs to be PHP in order to recognize PHP code.

    head.php
    
    <html>
    <head>
    <title>My Title!</title>
    <!-- Stylesheet/meta tags etc -->
    </head>
    <body>
    
    HTML:
    menu.php
    
    <ul id="menu">
      <li>Home</li><li>About Us</li><li>Contact</li>
    </ul>
    
    HTML:
    index.php
    
    <?php
    include "includes/head.php";
    include "includes/menu.php";
    ?>
    <h1>Welcome to my Homepage</h1>
    <p>Lipsom lorip blah blah</p>
    <?php include "includes/footer.php";?>
    
    PHP:
    aboutus.php

    
    <?php
    include "includes/head.php";
    include "includes/menu.php";
    ?>
    <h1>About Us</h1>
    <p>We are awesome!</p>
    <?php include "includes/footer.php";?>
    
    PHP:

    footer.php
    
    <!-- Footer code here -->
    </body>
    </html>
    HTML:
     
    scottlpool2003, Feb 21, 2013 IP
  6. Ronen1m

    Ronen1m Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #6
    jacksarlo and scottlpool2003



    Thanks a lot for your help!
    It works for a simple menu. just like in your example on top.

    Problems starting to accure when I'm trying my jQuery menu (taken from: http://apycom.com/).

    This is my menubar.php file: http://www.ronenmymon.com/MenuBar.php
    And this is my index.php: http://www.ronenmymon.com/index.php

    Getting some kind of 'no back link' error... do you know anything about it or should I address apycom.com ?

    Thanks again guys for your help !!
     
    Ronen1m, Feb 21, 2013 IP
  7. scottlpool2003

    scottlpool2003 Well-Known Member

    Messages:
    1,709
    Likes Received:
    48
    Best Answers:
    9
    Trophy Points:
    150
    #7
    Not entirely sure what the problem is. Could be because its a free script that requires a backlink.

    I did notice you're including the JQuery codes twice though.
     
    scottlpool2003, Feb 21, 2013 IP
  8. Ronen1m

    Ronen1m Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #8
    Yes it is !!
    Just added the backlink !!

    jQuery twice...? can you pinpoint where...?
     
    Ronen1m, Feb 21, 2013 IP
  9. scottlpool2003

    scottlpool2003 Well-Known Member

    Messages:
    1,709
    Likes Received:
    48
    Best Answers:
    9
    Trophy Points:
    150
    #9
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    >>>>>>>>>> HERE <<<<<<<<<<
     
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
     
    <html xmlns="http://www.w3.org/1999/xhtml">
     
    <head>
        <meta http-equiv="Content-Language" content="en-us" />
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Ronen Mymon :: Photographer</title>
        <style type="text/css">
            .style9 {
        border-width: 0px;
    }
     
        .style11 {
        font-size: 8pt;
        text-align: right;
        font-size: 8pt;
        text-decoration: none;
        color: #000000;
    }
     
        </style>
       
        <link type="text/css" href="menu.css" rel="stylesheet" />
        <!-- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script> -->
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript" src="menu.js"></script>
        <script src="Galleria/galleria-1.2.5.min.js"></script>       
     
    >>>>>>>>>>>> HERE <<<<<<<<<<<<<
     
    <script type="text/javascript">
     
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-23422417-1']);
      _gaq.push(['_trackPageview']);
     
      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      })();
     
    </script>
     
    <script>
       
        $(function(){
            $('.fadein img:gt(0)').hide();
            setInterval(function(){
              $('.fadein :first-child').fadeOut()
                .next('img').fadeIn()
                .end().appendTo('.fadein');},
              3500);
        });
     
        </script>
     
        <link type="text/css" href="menu.css" rel="stylesheet" />
        <!-- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script> -->
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript" src="menu.js"></script>
        <script src="Galleria/galleria-1.2.5.min.js"></script>       
     
       >>>>>>>>>> HERE <<<<<<<<<<
     
                   
    </head>
    
    HTML:
    If you reply with the exact contents (including PHP), we'll be able to help further. I think you've added the code to both pages but its impossible for me to know without the contents of those pages.
     
    scottlpool2003, Feb 21, 2013 IP
  10. scottlpool2003

    scottlpool2003 Well-Known Member

    Messages:
    1,709
    Likes Received:
    48
    Best Answers:
    9
    Trophy Points:
    150
    #10
    scottlpool2003, Feb 21, 2013 IP
  11. Ronen1m

    Ronen1m Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #11
    Thanks a lot for you help guys !!!

    You've been a great help :)
     
    Ronen1m, Feb 21, 2013 IP
  12. scottlpool2003

    scottlpool2003 Well-Known Member

    Messages:
    1,709
    Likes Received:
    48
    Best Answers:
    9
    Trophy Points:
    150
    #12
    No problem.
     
    scottlpool2003, Feb 21, 2013 IP
  13. Super_Vendor

    Super_Vendor Active Member

    Messages:
    317
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #13
    I'll tell you what I do, which seems to me to be much easier than the other responses. My menu will always be a .swf file. And of course it's that same file on every page. So if I make a change to the menu or add something, I just upload the new menu and overwrite the .swf file with exact same name. Then all of the pages will automatically load the new file.

    This works as long as you don't change the actual size (dimensions) of the menu.
     
    Super_Vendor, Feb 21, 2013 IP
  14. scottlpool2003

    scottlpool2003 Well-Known Member

    Messages:
    1,709
    Likes Received:
    48
    Best Answers:
    9
    Trophy Points:
    150
    #14

    Great idea, give him Flash which effectively writes off the entire mobile/tablet traffic.

    There's nothing wrong with including files using PHP, and I actually think it is easier than using SWF, saves a lot of bandwidth, saves space...
     
    scottlpool2003, Feb 22, 2013 IP
  15. Super_Vendor

    Super_Vendor Active Member

    Messages:
    317
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #15
    Damn i forgot about mobile not supporting flash. Yeah I guess in that case it wouldn't be ideal. Your sarcasm makes you appear very bitter. I hope your ventures are doing well for you.
     
    Super_Vendor, Feb 22, 2013 IP
  16. deathshadow

    deathshadow Acclaimed Member

    Messages:
    8,408
    Likes Received:
    1,502
    Best Answers:
    220
    Trophy Points:
    515
    #16
    Flashtard BS for a menu should NEVER be done on a website, you basically throw accessibility in the trash and for what, a few goofy animated effects?

    The same can be said if you need that bloated idiotic crap known as jQuery to build a menu -- good scripting should ENHANCE functionality, not supplant it... and any goofy effects or advantages you get from the likes of jQuery on a menu is typically the type of crap that has no business on a website in the first place.
     
    deathshadow, Feb 22, 2013 IP
  17. Original Hosting

    Original Hosting Active Member

    Messages:
    203
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    50
    #17
    If you don't want to use PHP then prehaps and Iframe would be a better solution. Create all of your individual pages without any headers or footers and then create one page with the Iframe in it with a header and a footer. Give the Iframe a name and put each menu link's target as the name of the Iframe :)
     
    Original Hosting, Feb 22, 2013 IP
  18. deathshadow

    deathshadow Acclaimed Member

    Messages:
    8,408
    Likes Received:
    1,502
    Best Answers:
    220
    Trophy Points:
    515
    #18
    Oh yes, iFrames -- the bleeding edge of 1997 sitebuilding methodologies that pisses all over accessibility -- SO worth suggesting.
     
    deathshadow, Feb 23, 2013 IP