RV: includes & globals
| From: | Cesar Aracena | Date: | Mon, 02 Dec 2002 06:06:54 +0000 |
| Subject: | RV: includes & globals | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-126677@lists.php.net to get a copy of this message | ||
Hi all,
I'm making a site with a dynamic menu based on IF statements and DB
queries, but have this little problem which I can't understand the
reason. My programming method is based upon an application.php file
which controls the hole site and paths, template files for the header &
footer and main PHP files which includes all the needed files that I
mentioned before.
As an example of this, the header TITLE tag has a <?=$TITLE?> variable
to take a different title for each page and after that, I put a
$LOCATION variable to tell the menu() function which page is being
displayed (different menus for products, about us, etc.) but the menu()
function (fetched from a library) is not recognizing this $LOCATION
variable. I'm declaring it as a GLOBAL inside the function, but nothing
happens. Here's part of my code:
This is part of my product's index.php file:
<SNIP>
<?
require ("../application.php");
$TITLE = "Joyería Mara";
$LOCATION = "";
include ("$CFG->templatedir/header.inc");
?>
<TR>
<TD VALIGN=top>
<P><!--COMIENZO DE CUERPO--><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0
WIDTH="100%" HEIGHT="100%"> <TR> <TD VALIGN=top WIDTH=200>
<P><TABLE
BORDER=0 CELLSPACING=0 CELLPADDING=15 WIDTH="100%"> <TR> <TD> <?
menu();
?>
</SNIP>
===========================
And this is the menu() function:
<SNIP>
function menu(){
GLOBAL $LOCATION;
if ($LOCATION = "productos"){
GLOBAL $MENU_NAME, $MENU_BACK, $MENU_LINK, $CFG;
$MENU_NAME = "Nosotros";
$MENU_LINK = "".$CFG->wwwroot."/nosotros";
$MENU_BACK = "000066";
menu_def();
unset($GLOBALS['MENU_BACK'], $GLOBALS['MENU_NAME'],
$GLOBALS['MENU_LINK']);
GLOBAL $MENU_NAME, $MENU_BACK, $MENU_LINK;
$MENU_NAME = "Productos";
$MENU_LINK = "".$CFG->wwwroot."/productos";
$MENU_BACK = "999999";
menu_def();
unset($GLOBALS['MENU_BACK'], $GLOBALS['MENU_NAME'],
$GLOBALS['MENU_LINK']);
GLOBAL $MENU_NAME, $MENU_BACK, $MENU_LINK;
$MENU_NAME = "Regístrese";
$MENU_LINK = "".$CFG->wwwroot."/registrese";
$MENU_BACK = "000066";
menu_def();
unset($GLOBALS['MENU_BACK'], $GLOBALS['MENU_NAME'],
$GLOBALS['MENU_LINK']);
GLOBAL $MENU_NAME, $MENU_BACK, $MENU_LINK;
$MENU_NAME = "Contacto";
$MENU_LINK = "".$CFG->wwwroot."/contacto";
$MENU_BACK = "000066";
menu_def();
unset($GLOBALS['MENU_BACK'], $GLOBALS['MENU_NAME'],
$GLOBALS['MENU_LINK']); } else if ($LOCATION = "nosotros"){ echo "hi";
}
else{ echo "none"; } }
</SNIP>
==============================
Any thoughts? Thanks
Cesar L. Aracena
icaam@icaam.com.ar
caracena@infovia.com.ar
(0299) 156-356688
Neuquén (8300) Capital
Argentina