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.

Include for Mega Menu

Discussion in 'PHP' started by Sveta, Aug 5, 2013.

  1. #1
    Hi everyone. I've got to build a website with over 50 pages on it and I'll be using a css3 mega menu. I know very little about php and have been told using an include for the menu and making the pages php pages I could easily modify the menu and it would update all the pages at one time.

    My question is...if this is correct then how do I make the include for the menu?
    Thanks in advance
    Sveta
     
    Sveta, Aug 5, 2013 IP
  2. SoftCloud

    SoftCloud Well-Known Member

    Messages:
    1,060
    Likes Received:
    28
    Best Answers:
    2
    Trophy Points:
    120
    #2
    You will need to make a separate file (we'll called it menu.php), which will hold the menu stuff.

    All you need to do then is on every page you make, put this line of PHP where you want the menu to show.
    <?php include("menu.php"); ?>
    PHP:
    Then, within menu.php you'd put all the HTML for the menu and everytime you update that file, it will automatically update the menu on all the pages where you have put the PHP "include" tag.

    Understand? :)
     
    SoftCloud, Aug 10, 2013 IP
  3. Sveta

    Sveta Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #3
    Thanks so much for your reply.
    Ok. I make a php page and call it menu.php.
    I then add the mega menu on that php page.
    I then make all the other pages on the site php pages.
    I then put menu.php include on the other pages where I want the menu located on the page.
    Correct, or am I still lacking something?

    Sveta
     
    Sveta, Aug 12, 2013 IP
  4. SoftCloud

    SoftCloud Well-Known Member

    Messages:
    1,060
    Likes Received:
    28
    Best Answers:
    2
    Trophy Points:
    120
    #4
    That's all correct. :)
     
    SoftCloud, Aug 13, 2013 IP
  5. Sveta

    Sveta Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #5
    I made a php page and saved it as menu.php and then put the menu on that page.
    I made another php page and tried these 3 things on the new php page where I want the menu but it still doesn't work.(menu doesn't show up on the page)
    menu.php
    <?php include('incl/menu.php'); ?>
    <?php include 'menu.php'; ?>
    What am I doing wrong.

    Thanks again
     
    Sveta, Aug 14, 2013 IP
  6. SoftCloud

    SoftCloud Well-Known Member

    Messages:
    1,060
    Likes Received:
    28
    Best Answers:
    2
    Trophy Points:
    120
    #6
    Guessing you have the files like so:
     - index.php
     - page1.php
     - page2.php
     - menu.php
    Code (markup):
    In index.php, you will just need to have just one include tag.
    <?php include("menu.php"); ?>
    PHP:
    :)
     
    SoftCloud, Aug 14, 2013 IP
  7. samyak

    samyak Active Member

    Messages:
    280
    Likes Received:
    7
    Best Answers:
    4
    Trophy Points:
    90
    #7
    Apart from menu.php what other files have you created. If you want to include the menu, then these files have to be .php files as well. There are ways to do this on HTML files, but since you said you are a beginner, lets not try that just yet.

    Also, what do you see when you view the menu.php from your browser. Do you see the menu or not.

    <?php include('incl/menu.php'); ?>

    have you put the menu.php on the folder "incl"?
     
    samyak, Aug 14, 2013 IP