ugrás a tartalomhoz

Menu parameter beszurasa minden oldalon

Anonymous · 2006. Aug. 30. (Sze), 11.04
Addott a kov. HTML kod (header.html):
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
  2. <html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">  
  3. <head>  
  4.  <title><?php if (defined('TITLE')) print TITLE ?></title>  
  5. <meta http-equiv="content-type" content="text/html; charset=iso-8859-2" />   
  6. <link rel="stylesheet" href="lib/style.css" />  
  7. <script type="text/javascript" src="lib/banner.js"></script>  
  8. </head>  
  9. <body>  
  10. <div id="content">  
  11. <h1 title="Site design"></h1>  
  12. <ul id="top">  
  13.   <li><a href="index.php" id="active_top">Home</a></li>  
  14.   <li><a href="">Login</a></li>  
  15.   <li><a href="contact.php">Contact</a></li>  
Van egy menu harom opcioval: Home, Login es Contact. Ezek az opciok az utolso harom sorban szerepelnek a fenti kodban.

A home opcionak van egy specialis parametere (id="active_top").
Most letrehozok egy index.php nevu filet a kov. tartalomal:
  1. <?php  
  2. define ('TITLE''Home');  
  3. require ("header.html");  
  4.   
  5. print 'Website under construction';  
  6.   
  7. require ("bottom.html");  
  8. ?>  
Az index.php lap az (id="active_top") opcioval latszik. De tegyuk fel ha meg letrehozok egy masik lapot, peldaul contact.php :
  1. <?php  
  2. define ('TITLE''Contact');  
  3. require ("header.html");  
  4.   
  5. print 'Contact';  
  6.   
  7. require ("bottom.html");  
  8. ?>  
Most az (id="active_top") opcio mar nem szerepel az oldalon.

Hogy lehetne ezt ugy megcsinalni, hogy minden PHP lapon megadjam, hogy hasznalja azt az (id="active_top") opciot.

De peldaul ha Contact.php-ben hasznalom akkor index.php-ben ne legyen hasznalva.