Menu parameter beszurasa minden oldalon
Addott a kov. HTML kod (header.html):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:Az index.php lap az (id="active_top") opcioval latszik. De tegyuk fel ha meg letrehozok egy masik lapot, peldaul contact.php :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.
■ - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title><?php if (defined('TITLE')) print TITLE ?></title>
- <meta http-equiv="content-type" content="text/html; charset=iso-8859-2" />
- <link rel="stylesheet" href="lib/style.css" />
- <script type="text/javascript" src="lib/banner.js"></script>
- </head>
- <body>
- <div id="content">
- <h1 title="Site design"></h1>
- <ul id="top">
- <li><a href="index.php" id="active_top">Home</a></li>
- <li><a href="">Login</a></li>
- <li><a href="contact.php">Contact</a></li>
A home opcionak van egy specialis parametere (id="active_top").
Most letrehozok egy index.php nevu filet a kov. tartalomal:
- <?php
- define ('TITLE', 'Home');
- require ("header.html");
- print 'Website under construction';
- require ("bottom.html");
- ?>
- <?php
- define ('TITLE', 'Contact');
- require ("header.html");
- print 'Contact';
- require ("bottom.html");
- ?>
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.