Tab Selector?

    Date: 12/11/07 (Web Development)    Keywords: php, templates, css, html

    i am wanting to make my tab nav a php include such that i can easily change the menu for all pages as needed. i am using CSS class on the LI element to indicate selected. so how to have that show up for each page without hard coding the menu or using parameterized url?

    i know i could use dreamweaver templates for this but i forget how i did that before, so i am trying to do with php now [unless you suggest better/best way to do?]:

    [hack]

    eg. in each page:

    $_GLOBAL["tab"]=3; include 'common/menu.php';

    then in menu.php

    $menu=array("Home"=>"#","About Us"=>"#","Products"=>"#","Services"=>"#","Contact Us"=>"#");
    $it=$_GLOBAL["tab"];$j=0;

    function make_tabs($value,$key)
    {
    global $it,$j;
    echo ($j++ != $it) ? '

  1. ' : '
  2. ';
    echo "$key
  3. \n";
    }

    array_walk($menu,"make_tabs");


    output, where "it" would appear as the selected tab (used []'s for posting purposes):

    [li][a href="#" class="it"]Home[/a][/li]
    [li][a href="#"]About Us[/a][/li]
    ...


    [/hack]

    i know this is very crude but was trying to do this before posting here. this works fine but is obviously inelegant.. i'm sure you've all had to deal with this in some form or another. i'm embarrassed to ask.

    also this method doesn't allow for use of HTML "title" attribute as i'm quite fond of using that for menus and such. the dreamweaver template method would be static but would be versatile as well.

    open to discussion/recommendations/examples. thanks

    Source: http://community.livejournal.com/webdev/452377.html

« lightbox || spambots? »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home