Hi it's me again :-) i made the changes i describe lower, but instead of the new pic for submenu there's just an empty square :-(
so the page.inc
has the following operation DisplayButton() which outputs a single menu button. If the button is to point to the page we are on, we are displaying an inactive button instead, which looks slightly different, and doesn't link anywhere.
this keeps the page consistent, etc.
and also - there's an operation IsURLCurrentPage() which determines if the URL for a button points to the current page.
The string function strpos() is used to see if the URL given is contained in one of the server set variables.
The statement strpos ($GLOBALS["SCRIPT_NAME], $url) will return either a number if the string in $url is inside the global variable SCRIPT_NAME, or false if it's not.
function DisplayMenu($buttons)
{
echo "<table width = \"100%\" height=25px bgcolor = #9999cc cellpadding = 0 cellspacing = 4>\n";
echo " <tr>\n";
//calculate button size
$width = 100/count($buttons);
while (list($name, $url) = each($buttons))
{
$this -> DisplayButton($width, $name, $url, !$this->IsURLCurrentPage($url));
}
echo " </tr>\n";
echo "</table>\n";
}
function IsURLCurrentPage($url)
{
if(strpos( $GLOBALS["SCRIPT_NAME"], $url )==false)
{
return false;
}
else
{
return true;
}
}
function DisplayButton($width, $name, $url, $active = true)
{
if ($active)
{
echo "<td width = \"$width%\">
<a href = \"$url\">
<img src = \"images/arrow.jpg\" height=20 width=20 alt = \"$name\" border = 0></a>
<a href = \"$url\"><span class=menu>$name</span></a></td>";
}
else
{
echo "<td width = \"$width%\">
<img src = \"images/URLarrow.jpg\">
<span class=menu>$name</span></td>";
}
}
now at the next page we need a submenu and row2buttons. i wanted submenu look different,
so i copied the code from the page.inc to override in the page services.php
i changed the color of teh table in
" function Display2Menu($row2buttons)
{
echo "<table width = \"100%\" height=15px bgcolor = #99cc99 cellpadding = 0 cellspacing = 4>\n";
echo " <tr>\n";"
and also
chnaged img src to a different image for the submenu(arrowrow.jpg):
" function DisplayButton($width, $name, $url, $active = true)
{
if ($active)
{
echo "<td width = \"$width%\">
<a href = \"$url\">
<img src = \"images/arrowrow.jpg\" height=15 width=15 alt = \"$name\" border = 0></a>
<a href = \"$url\"><span class=menu>$name</span></a></td>";"
the whole code of the page services.php:
<?
require ("page.inc");
class ServicesPage extends Page
{
var $row2buttons = array("Translation" => "translation.php",
"Travel" => "travel.php",
"Visa" => "visa.php");
function Display()
{
echo "<html>\n<head>\n";
$this -> DisplayTitle();
$this -> DisplayKeywords();
$this -> DisplayContentdescription();
$this -> DisplayStyles();
echo "</head>\n<body cellspacing=0 cellpadding=0 leftmargin=0 rightmargin=0 topmargin=0 marginheight=0 marginwidth=0>\n";
$this -> DisplayHeader();
$this -> DisplayMenu($this->buttons);
$this ->Display2Menu($this->row2buttons);
echo $this->content;
$this -> DisplayFooter();
echo "</body>\n</html>\n";
}
function Display2Menu($row2buttons)
{
echo "<table width = \"100%\" height=15px bgcolor = #99cc99 cellpadding = 0 cellspacing = 4>\n";
echo " <tr>\n";
//calculate button size
$width = 100/count($row2buttons);
while (list($name, $url) = each($row2buttons))
{
$this -> DisplayButton($width, $name, $url, !$this->IsURLCurrentPage($url));
}
echo " </tr>\n";
echo "</table>\n";
}
function IsURLCurrentPage($url)
{
if(strpos( $GLOBALS["SCRIPT_NAME"], $url )==false)
{
return false;
}
else
{
return true;
}
}
function DisplayButton($width, $name, $url, $active = true)
{
if ($active)
{
echo "<td width = \"$width%\">
<a href = \"$url\">
<img src = \"images/arrowrow.jpg\" height=15 width=15 alt = \"$name\" border = 0></a>
<a href = \"$url\"><span class=menu>$name</span></a></td>";
}
else
{
echo "<td width = \"$width%\">
<img src = \"images/URLarrow.jpg\">
<span class=menu>$name</span></td>";
}
}
}
$services = new ServicesPage();
$content = "<table background color=#ffffff border=0 cellspacing=20 cellpadding=20>
<tr><td>
<p>Our philosophy is to provide the best possible service for the lowest price.</p></td></tr></table>";
$services ->SetContent($content);
$services ->Display();
?>