[thelist] PHP - good ways to indicate current page in navigation?

Tom Dell'Aringa pixelmech at gmail.com
Mon Jul 17 17:10:48 CDT 2006

Hi folks,

It's been awhile since I've done any PHP. Currently I am doing a simple web
site that has some horizontal navigation. I'd like to indicate what section
the user is in by writing out a class on a LI item dynamically server side.
So for example, I might have 2 categories, home and services. Services is a
drop down with 4 items under it. If the user clicks on services, or any of
the subpages, I want to write out that class on the services LI so I can
indicate to the user they are in the services section.

The hacked up way I have done it in the past on simple sites was to do
something like this:

if($pageName == "home") { ?> class="activePage" <?php } ?>

where $pageName was set locally in each page. This is lame of course, and
hardly scales well - nor does it take into account pages within a
section/directory. Can anyone point me to some examples along this line?

Please CC me on all replies at tom at g mail dot com.



More information about the thelist mailing list