Results 1 to 2 of 2

Thread: menu in php templates...

  1. #1
    Join Date
    Nov 2008
    Posts
    52
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default menu in php templates...

    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="www.one.com" class="<?php echo "$head001";?>">One</a></li>
    <li><a href="www.two.com" class="<?php echo "$head002";?>">Two</a></li>
    <li><a href="www.thr.com" class="<?php echo "$head003";?>">Three</a></li>
    <li><a href="www.fou.com" class=<?php echo "$head004";?>>Four</a></li>
    <li><a href="www.fiv.com" 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";

    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.

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by pepe_lepew1962
    The variable current is in my external css file ...
    Do you mean that you are declaring the variable in your css file (as opposed to in your php file)? CSS does not understand php code.

    Quote Originally Posted by pepe_lepew1962
    and changes the appearance.
    Meaning it does work? I would assume not, since you're asking for help. Maybe I don't understand your meaning, here.

    Quote Originally Posted by pepe_lepew1962
    Simple, but for some reason, the variable is not being carrier over. Can you please help.
    "Carried over" from where to where?

    = = = = = = = = = =
    I think you may be misunderstanding a basic detail of how PHP works. (If you do understand this, please bear with me; many people do not.)

    PHP happens first, on your webserver. At this point, there is no such thing as "html" or "css" or "javascript" or "sql." PHP has no idea any of these things exist. Everything that you output via PHP is text, nothing more, nothing less. After it is output (to the browser, database server, etc.), it may be parsed as some other language or markup.

    HTML/CSS/JavaScript happens later, on the user's browser. At this point, there is no such thing as "php." The browser has no idea that php ever existed. If you give it PHP code, it will be treated as either plain text or badly formed HTML / CSS / JavaScript.

Similar Threads

  1. Accordion Menu script not working with Dreamweaver Templates
    By jeanninejack in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 10-05-2010, 02:35 PM
  2. Templates
    By Tabo in forum PHP
    Replies: 2
    Last Post: 07-28-2008, 12:13 PM
  3. xml templates using php
    By rajeevp in forum PHP
    Replies: 0
    Last Post: 06-23-2008, 11:25 AM
  4. Using Different CSS templates
    By Seandudding in forum CSS
    Replies: 2
    Last Post: 05-19-2008, 03:06 PM
  5. Making PHP Templates
    By tech_support in forum Coding tips & tutorials threads
    Replies: 1
    Last Post: 01-14-2008, 01:16 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •