Page 1 of 5 123 ... LastLast
Results 1 to 10 of 45

Thread: included menu in every page

  1. #1
    Join Date
    Apr 2007
    Posts
    149
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default included menu in every page

    Ok, here's my situation... i have a website and i want to create a file called "header.php" and then include it on every page, but how can i put a menu like this one on that header and make it for example if im on contact us, make the contac us tab selected and if the index.php, that tab selected?
    i hope you understand and can help me....

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Include the same .js scripts on each page. Then use <?php include('header.php'); ?> to include any needed html.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Apr 2007
    Posts
    149
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks for responding, but i already have done that, and it is working but i don't know how to set the menu tab to be selected for each page:

    Code:
     <li><a href="index.php" class="current" title="">Home</a></li>
                          <li><a href="Classes.html" title="">Classes</a></li>
    
                          <li><a href="products.php" title="">Products</a></li>
    If you see that class="current" is when im on the home page, then if i want it to be selected when im on the "products" page for example, i have to put the class="current" on that page:

    Code:
     <li><a href="index.php" title="">Home</a></li>
                          <li><a href="Classes.html" title="">Classes</a></li>
    
                          <li><a href="products.php" class="current"title="">Products</a></li>

    But how can i do that when i only have on code that im including on every page? in other words, how can I have the appropriate menu selection stay active when the corresponding page from the include page loads? i hope i have explained myself better this time
    Last edited by remp; 01-03-2008 at 06:50 AM.

  4. #4
    Join Date
    Nov 2007
    Posts
    346
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    hehe, same question I have.

  5. #5
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    No, you just set the onClick to set it as current.

    for a better idea see this
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  6. #6
    Join Date
    Nov 2007
    Posts
    346
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I think he wants to have his "currents" on his menus done automatically. Like my post, http://www.dynamicdrive.com/forums/s...ad.php?t=28042

  7. #7
    Join Date
    Apr 2007
    Posts
    149
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    ok. i got the script, i include it on the header page, but how do i set it on the menu? in other words how do i set the onclick function?
    Last edited by remp; 01-03-2008 at 11:37 PM.

  8. #8
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Through the CSS:

    Code:
    #menu a.active {color:red;}
    #content a.active {color:#333;}
    #footer a.active {text-decoration:underline;}
    The page should find itself, so to speak.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  9. #9
    Join Date
    Nov 2007
    Posts
    346
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hey Blizzard, can you tell me how I would work it out with my menu? http://www.athletes4excellence.com/layout.php

  10. #10
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Okay, your's afe, won't work with #nogo as the link source, so a single test page won't happen for you. Your's is hard coded into the nav menu you have. Currently the "Cross Country" link is "active" and you can see this in the source:

    Code:
    <ul class="current">
      <li><a href="#nogo"><b>Cross Country </b><!--[if IE 7]><!--></a><!--<![endif]-->
    <!--[if lte IE 6]><table><tr><td><![endif]-->
    
    <div class="select_sub show">
    	<ul class="sub">
    		<li><a href="#nogo">The Hay Wain</a></li>
    		<li><a href="#nogo">Brighton Beach</a></li>
    		<li><a href="#nogo">Malvern Hall</a></li>
    		<li class="sub_show"><a href="#nogo">Salisbury Cathedral</a></li>
    		<li><a href="#nogo">Weymouth Bay</a></li>
    
    	</ul>
    </div>
    <!--[if lte IE 6]></td></tr></table></a><![endif]-->
    </li>
    </ul>
    This is the code for the Cross Country button. Notice the part i red? Let's look at the next button's code...

    Code:
    <ul class="select">
      <li><a href="#nogo"><b>Soccer</b><!--[if IE 7]><!--></a><!--<![endif]-->
    <!--[if lte IE 6]><table><tr><td><![endif]-->
    <div class="select_sub">
    	<ul class="sub">
    		<li><a href="#nogo">The Girl with Green Eyes</a></li>
    
    		<li><a href="#nogo">The Dream</a></li>
    		<li><a href="#nogo">Woman in Blue</a></li>
    		<li><a href="#nogo">The Yellow Dress</a></li>
    		<li><a href="#nogo">The Piano Lesson</a></li>
    	</ul>
    </div>
    <!--[if lte IE 6]></td></tr></table></a><![endif]-->
    </li>
    
    </ul>
    See the difference? On the page that you go to you will need to change "select" to "current" for each respective link.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

Bookmarks

Posting Permissions

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