Skip to content Skip to sidebar Skip to footer

Css Sprites And Php Using Dynamic Menu Highlighting Not Working With Loop Function

On this site: http://jumpthru.net/newsite/vision/ I am using CSS sprites for my navigation with PHP else statements to show the active state for the current page. All of the pages

Solution 1:

I have a solution that is a bit different than what you are looking for, but is a much better solution to what you are doing.

PHP:

<?phpif ( is_page('vision') ) 
  $page = 'vision';
elseif ( is_page('team') )
  $page = 'team';
elseif ( is_page('commentary') )
  $page = 'blog';
elseif  ( is_page('organizations') ) 
  $page = 'org';

?><bodyid="page-<?phpecho$page; ?>">
...

Note about above PHP: If you had a get_page_id() function, you could simplify this a lot more. by simply having <body id="page-<?php get_page_id(); ?>">

HTML:

<ulid="sidenav"><liclass="visionside"><ahref="#">...</a></li><liclass="teamside"><ahref="#">...</a></li><liclass="blogside"><ahref="#">...</a></li><liclass="orgside"><ahref="#">...</a></li></ul>

CSS:

body#page-vision#sidenavli.visionsidea,
#sidenavli.visionsidea:hover {
   ...
}

Note about above CSS: There are two lines listed above that you can style together - the current state, and the hover state. This will make the current state display when you hover over the nav, regardless of which nav is the "current" nav.

Seeing that you're interested in using CSS Sprites, I would definitely recommend that you read up on this article.

Post a Comment for "Css Sprites And Php Using Dynamic Menu Highlighting Not Working With Loop Function"