ItemActive on page load with extra PHP vars

Home Forums Older releases 1.0.x ItemActive on page load with extra PHP vars

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #8511
    RonP
    Participant

    Still very happy with your wonderful menu-script!
    I am, however, running into the problem that menu-items are not highlighted when a PHP-page is (re)loaded with extra vars.

    For example:

    activates the corresponding menu-item correctly.
    But when the same page is loaded with a extra vars, menu-item is not activated:


    etc.

    Do I have to change some settings for the script to ignore those extra vars in the URL? Or can this be resolved with an extra script?

    #8512
    RonP
    Participant

    Sorry code was lost… Here the examples:

    index.php?id=1 activates the corresponding menu-item correctly.
    But when the same page is loaded with extra vars, menu-item is not activated:

    index.php?id=1&project=5 > menu-item index.php?id=1 not activated
    index.php?id=1&project=5&var=foo > menu-item index.php?id=1 not activated

    #8643
    admin
    Keymaster

    Well, I suppose you understand that adding a single parameter changes the page URL (Google considers these completely different pages too) so unless you are able to change the “href” attribute of the menu item (that you would like to be highlighted) to correspond to the new page URL too, the script will not highlight it.

    So you would need to use some other “manual” solution – e.g. output the “current” class to the proper <a> element when needed via PHP.

    #8644
    RonP
    Participant

    That is ideed what I did:

    Added extra ID to <a> element of menu items (id=menuItem_1, id=menuItem_2, id=menuItem_3, etc.)

    Then alter style of menu item via js at the end of php script:

    echo("
      <script> 
    	$(document).ready(function() { 
    	  $('#menuItem_4').css({'background-color': '#2d8ebb', 'color': '#fff'});
    	}); 
      </script>
    ");
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Register

You will be emailed a link to set your password.

Login

Lost password?