Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Nov 2002
    Location
    Israel
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Menu with "a name" that works only in chrome

    hi
    I have a menu included in all my pages, this is an item of the menu with his own submenu

    packaging.php' => array(
    'text' => 'Package Design',
    'submenu' => array('packaging.php#Title0' => array('text' => 'Title0'),
    'packaging.php#Title1' => array('text' => 'Title1'),
    'packaging.php#Title2' => array('text' => 'Title2'),
    'packaging.php#Title3' => array('text' => 'Title3'),
    'packaging.php#Title4' => array('text' => 'Title4'),
    'packaging.php#Title5' => array('text' => 'Title5')
    )

    In this case i'm not opening different pages, when i click i want to be redirected to a different picture in the same page but i have 2 problems:
    1) First problem: When highlighted the menu and submenu here don't behave as the rest of the menu items their color shoul change to red
    2) Second problem: the links work only in Chrome

    Can someone help me with this
    Thanks

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    First problem is rendering. That's not a PHP issue.
    Second problem cannot be determined by what you have posted here.

  • #3
    New Coder
    Join Date
    Nov 2002
    Location
    Israel
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What is a rendering problem, and where should i post this post?

  • #4
    New Coder
    Join Date
    Nov 2002
    Location
    Israel
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    the changing color is a function that i included in an external file function.php

    <?php
    // function to draw menu (top and left)
    function draw_menu($script, $items, $div_id) {
    // start the list for the menu
    $menu = ' <ul id="list-nav">';
    // loop through the array with menus and submenus
    foreach($items as $url => $val) {
    $text = $val['text'];
    if($script == $url) {
    // if the item in the array is the current page, highlight it
    $menu .= '<li><a style="color:#eb0089" href="#nogo"> '. $text . ' </a></li>';
    } else {
    // else display it as usual link
    $menu .= '<li><a href="' . $url . '">' . $text . '</a></li>';
    }
    }
    // end the list
    $menu .= '</ul>';
    return $menu;
    }
    // function to draw submenu below the main menu on left side
    function draw_sub_menu($script, $items) {
    // find the correct submenu items to draw
    foreach($items as $url => $val) {
    // if the current page is on the top level (index.php, book.php...)
    if($script == $url) {
    if(isset($val['submenu']) && !empty($val['submenu'])) {
    $submenu = draw_menu($script, $val['submenu']);
    return $submenu;
    } else {
    return '';
    }
    }
    // if the current page is not on the top level, examine each submenu entry
    if(isset($val['submenu']) && !empty($val['submenu'])) {
    if($script == $val['submenu']['url']) {
    $submenu = draw_menu($script, $val['submenu']);
    return $submenu;
    }
    }
    }
    // if no submenus were drawn return empty string
    return '';
    }
    ?>

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    "Colour" is a rendering issue. Its HTML/CSS not PHP. PHP does not have the capability to render HTML or CSS.

  • #6
    New Coder
    Join Date
    Nov 2002
    Location
    Israel
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If i call in a php function a different color as in the function.php page:
    $menu .= '<li><a style="color:#eb0089" href="#nogo"> '. $text . ' </a></li>';

    this is PHP, because i have a problem with the function that changes the color not with the color style

  • #7
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    No, that's an HTML issue, not a PHP one. All that matters on the PHP side is that $menu is appended with $text and the string of tags surrounding it. The rest is HTML's job to render.
    What function are you talking about to change a colour style? PHP's incapable of responding to client events, so this leads me to believe that you are referring to a javascript function.

  • #8
    New Coder
    Join Date
    Nov 2002
    Location
    Israel
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't have javascript in the code, this is the line:

    // if the item in the array is the current page, highlight it
    $menu .= '<li><a style="color:#eb0089" href="#nogo"> '. $text . ' </a></li>';
    } else {
    // else display it as usual link

  • #9
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Yes and? That will append to $menu a list item with a given link with $text. If that shows in your source code, then PHP is not the problem.


  •  

    Posting Permissions

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