Start a new discussion

To start a new discussion please visit the discussions section of the GitHub home page of the project.

Discussions on GitHub

You can also search our old self-hosted forums for any useful information below but please note that posting new content here is not possible any more.

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)
  • The forum ‘1.0.x’ is closed to new topics and replies.