• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 76
  • Last Modified:

How to make list items like php.net where the list item highlights for current function.

I have a long category list. I don't want to have an if statement for each list item to echo out one of two css properties, (highlight or no-highlight). PHP.net has an example of a vertical list on the right side of the page that highlights the current page in red. Is there an efficient way to code this functionality? Thanks.

  • 2
1 Solution
Ray PaseurCommented:
Yes.  It's usually done via a templating system.  The CSS classes are set in the PHP script that generates the web page.  The web page uses HEREDOC notation to inject the CSS class into the generated HTML in order to highlight the appropriate data elements.  This requires some forethought and planning, but the basic idea is an array of links, a matching array of CSS classes, and a bit of logic to set the class on the active link.
kadinAuthor Commented:
Thanks again Ray. I think I get the idea.
Ray PaseurCommented:
Thanks for the points.  If you need an example, I can probably come up with one tomorrow.  But a "view source" of the PHP web page will give a lot of good hints.

Best regards, ~Ray
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now