template menu problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pepe_lepew1962
Forum Commoner
Posts: 44
Joined: Thu Nov 20, 2008 10:29 am

template menu problem

Post by pepe_lepew1962 »

Hello:

I am trying to create templates for my files and I am having a problem with getting the menu to work properly. I have 3 template files, head.php, main.php and foot.php. The head.php contains the following menu html:

<li><a href="page1.php" class="<?php echo "$head001";?>">One</a></li>
<li><a href="page2.php" class="<?php echo "$head002";?>">Two</a></li>
<li><a href="page3.php" class="<?php echo "$head003";?>">Three</a></li>
<li><a href="page4.php" class=<?php echo "$head004";?>>Four</a></li>
<li><a href="page5.php" class="<?php echo "$head005";?>">Five</a></li>

In the main.php, I would like to have 1 variable for what the status of the menu is for that page. For example when the person is on page 3, the class should be current.

$head003 = "Current";
include("head.php");

The variable current is in my external css file and changes the appearance. Simple, but for some reason, the variable is not being carrier over. Can you please help.
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: template menu problem

Post by Eric! »

So what happens? Are you getting a warning because $head001 is not defined?

What does the output HTML look like?
pepe_lepew1962
Forum Commoner
Posts: 44
Joined: Thu Nov 20, 2008 10:29 am

Re: template menu problem

Post by pepe_lepew1962 »

What happens is nothing. My css class is suppose to change the background color, in this example. The html is empty, like " ".
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: template menu problem

Post by Eric! »

Then you are probably getting an error that is stopping your code.

Turn on your error reporting and see what you get. Also select VIEW SOURCE in your browser to see if the error is output and mixed with your HTML...some browsers allow ctrl-U for a short cut to view source.

Code: Select all

error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
Post Reply