www.webdeveloper.com
Results 1 to 7 of 7

Thread: header.php and footer.php markup

  1. #1
    Join Date
    Dec 2008
    Posts
    93

    header.php and footer.php markup

    Hi all,

    Does anybody tell me what happens if I seperate header.php and footer.php files from the template file?

    How to tell browser to read my code in header/footer.php?

  2. #2
    Join Date
    Mar 2008
    Posts
    123
    PHP Code:
    <?php
    include "header.php";
    ?>

    Body of page

    <?php
    include "footer.php";
    ?>

  3. #3
    Join Date
    Dec 2008
    Posts
    93

    header.php and footer.php problem

    Thanks Sushi for you help... I've done this separation and now I've got two files (header.php & footer.php) which are linked with every other php file of my website.

    The problem now is with the states of buttons (menu). My main menu is in header.php and is always the same. I made a little triangle that should appear in its palce in a menu, which tell the navigation of the user.

    How can I do that in header.php? Is there any way?

    Thanks,
    A

  4. #4
    Join Date
    May 2009
    Posts
    17
    While that can be done in many ways, I tend to call the global variable $_SERVER["PHP_SELF"]. This variable contains the name of the current file.

    Code:
    <?php if($_SERVER["PHP_SELF"] == "about.php"){ ?>
       <a class="active" href="about.php">About</a>
    <?php }else{ ?>
       <a href="about.php">About</a>
    <?php } ?>
    Last edited by FRKT; 05-13-2009 at 04:38 AM.

  5. #5
    Join Date
    Dec 2008
    Posts
    93

    Red face header.php and footer.php markup

    Thanks FRKT,

    I've got the idea

    I just need more help... becuase I need more rules to add to this logical statement:

    If Menu 1, SubMenu1, Submenu2, Submenu3,... then....<a class="active" href="menu1.php">Menu1</a>

    If Menu 2, SubMenua, Submenub, Submenuc,... then....<a class="active" href="menu2.php">Menu2</a>

    How can I do this?

  6. #6
    Join Date
    May 2009
    Posts
    17
    You'd need to create a variable array in which you specify all items contained within a specified menu, and then have PHP check whether the name of the current document matches any of the strings in that array.

    Code:
    <?php $services = array("service1.php", "service2.php", "service3.php"); ?>
    
    <?php if(in_array($_SERVER["PHP_SELF"], $services)){ ?>
       <a class="active" href="services/">Services</a>
          (previous code goes here)
    <?php }else{ ?>
       <a href="services/">Services</a>
    <?php } ?>

  7. #7
    Join Date
    Dec 2008
    Posts
    93
    Dear FRKT,

    Thanks for your help! I'm not good at coding... so I would like to ask you for more help...

    Here is my header.php file code:

    <!DOCTYPE php PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <php xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/php; charset=utf-8" />
    <title>My Company</title>
    </head>
    <body>
    <div id="header">
    <div class="header-area">
    <div class="header-content">
    <div class="wrap">
    <h1 class="logo"><a href="index.php">Company</a></h1>
    <em>My Company</em>
    <form action="">
    <fieldset class="form">
    <div>
    <input class="text" type="text" value="search"/>
    </div>
    <input class="img" type="image" src="images/btn-go.gif"/>
    </fieldset>
    </form>
    </div>
    <ul id="MenuBar1" class="MenuBarHorizontal">
    <li><a class="MenuBarItemSubmenu" href="#">About us</a>
    <ul>
    <li><a href="overview.php">Overview</a></li>
    <li><a href="partnerships.php">Partnerships</a></li>
    </ul>
    </li>
    <li> <a style="background:url(images/icon-active.gif) no-repeat 50&#37; 100%;" class="MenuBarItemSubmenu" href="#">SERVICES</a>
    <ul>
    <li><a class="MenuBarItemSubmenu" href="services.php">Services</a></li>
    <li><a href="it.php">IT</a></li>
    <li><a href="1.php">Center</a></li>
    </ul>
    </li>
    <li><a class="MenuBarItemSubmenu" href="#">TRAININGS</a>
    <ul>
    <li><a class="MenuBarItemSubmenu" href="T0.php">T0</a></li>
    <li><a href="Training1.php">T1</a></li>
    <li><a href="Training2.php">T2</a></li>
    </ul>
    </li>
    </ul>
    </li>
    <li><a class="MenuBarItemSubmenu" href="#">EVENTS</a>
    <ul>
    <li><a class="MenuBarItemSubmenu" href="calendar.php">Calendar</a></li>
    <li><a href="news.php">Events</a></li>
    <li><a href="archives.php">Archives</a></li>
    </ul>
    </li>
    </ul>
    </div>
    </div>
    </div>
    </body>
    </php>

    Which code exacly do I have to put in here in order to make my menu function properly?

    Thanks very much,
    A

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