Web Analytics Made Easy -
StatCounter PHP Image Menu - CodingForum

Announcement

Collapse
No announcement yet.

PHP Image Menu

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PHP Image Menu

    This menu works great but I would like to replace the pages array with images. I have two images for each menu item, one for on and another for the off state. Any ideas on how to make this work would be appreciated.

    -plushtoy

    <?php
    function show_sidebar($cur_section, $cur_page = "none", $cur_subsec = "none"){
    $arr_sbar_content = array("overview" => array("pages" => array("overview","solutions","capabilities","login"),
    "href" => array("overview.php","solutions.php","capabilities.php","links.php"),
    "graphic" => "menu_spacer.gif",
    ));


    $graphic = $arr_sbar_content[$cur_section]["graphic"];
    $secRoot = $arr_sbar_content[$cur_section]["root"];
    if($arr_sbar_content[$cur_section]["pages"]){
    echo '<div class="sbar_pad"><span class="sbar_nav">';
    for ($i = 0; $i < count($arr_sbar_content[$cur_section]["pages"]); $i++){
    $is_last = ( $i == ( count( $arr_sbar_content[$cur_section]["pages"] ) - 1) );
    $thisPage = ereg_replace('[^a-zA-Z0-9]','_',$arr_sbar_content[$cur_section]["pages"][$i]);
    if($arr_sbar_content[$cur_section]["pages"][$i] == $cur_page){
    echo '<span class="current_page"><a href="'.$secRoot.$arr_sbar_content[$cur_section]["href"][$i].'">'.$arr_sbar_content[$cur_section]["pages"][$i].'</a></span>';
    }
    else{
    echo '<a href="'.$secRoot.$arr_sbar_content[$cur_section]["href"][$i].'">'.$arr_sbar_content[$cur_section]["pages"][$i].'</a>';
    }
    if ( ! $is_last ) {
    echo '<img src="images/'.$graphic.'" border="0">';
    }
    if($arr_sbar_content[$cur_section]["sub_pages"][$thisPage]){
    echo '<div class="sbar_morepad">';
    for($j = 0; $j < count($arr_sbar_content[$cur_section]["sub_pages"][$thisPage]); $j++){
    if($arr_sbar_content[$cur_section]["sub_pages"][$thisPage][$j] == $cur_page and $thisPage == ereg_replace('[^a-zA-Z0-9]','_',$cur_subsec)){
    echo '<span class="current_page"><a href="'.$secRoot.$arr_sbar_content[$cur_section]["sub_href"][$thisPage][$j].'">'.$arr_sbar_content[$cur_section]["sub_pages"][$thisPage][$j].'</a></span>';
    }
    else{
    echo '<a href="'.$secRoot.$arr_sbar_content[$cur_section]["sub_href"][$thisPage][$j].'">'.$arr_sbar_content[$cur_section]["sub_pages"][$thisPage][$j].'</a>';
    }
    }
    echo '</div>';
    }
    }
    echo '</span></div>';
    }
    }
    ?>

  • #2
    save images in array.
    take two different array on for on and one for off.
    write css for a visited.

    Comment

    Working...
    X