Solved

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

Posted on 2015-02-20
3
65 Views
Last Modified: 2015-02-20
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.

http://us3.php.net/manual/en/function.time.php
0
Comment
Question by:kadin
  • 2
3 Comments
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 40622511
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.
0
 

Author Closing Comment

by:kadin
ID: 40622521
Thanks again Ray. I think I get the idea.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 40622524
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
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now