coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 themes/skins/templates => Topic started by: steveeh131047 on March 19, 2008, 01:04:51 PM

Title: [Solved]: Problem identifying calling URL in PHP script
Post by: steveeh131047 on March 19, 2008, 01:04:51 PM
With some assistance from Nibbler I now have cpg nicely integrated into my web site. Just one feature doesn't work.

I use a PHP script to dynamically generate my Navigation Bar which is called as part of {CUSTOM_HEADER} - it mostly works fine. However there are a couple of places in the script where I check the calling URL so that I can highlight the current page in the Navigation Bar, and I can generate a "breadcrumb" string. Neither of these elements work.

I'm using:  $url=$_SERVER['PHP_SELF']; to pick up the URL, but if I echo $url at this point in the script it is null.

I could just hard-code the Navigation Bar for the gallery page, but it would be nice to use the script if possible. Any ideas what might be wrong?

Steve
Title: Re: Problem identifying calling URL in PHP script
Post by: Nibbler on March 19, 2008, 01:24:43 PM
We overwrite $_SERVER['PHP_SELF'] in init.inc.php, although it shouldn't be null. You can use $ORIGINAL_PHP_SELF instead which contains the original value.
Title: Re: Problem identifying calling URL in PHP script
Post by: steveeh131047 on March 19, 2008, 02:09:27 PM
Nibbler,

$ORIGINAL_PHP_SELF also seems to be null.

If I simply insert echo $ORIGINAL_PHP_SELF early in my script would I expect to see something? I'm no expert on PHP but could it be something to do with declaring variables as Global?

Thanks for your help.
Steve
Title: Re: Problem identifying calling URL in PHP script
Post by: Nibbler on March 19, 2008, 02:16:35 PM
Yeah, if you use it inside a function you need to global it.
Title: [Solved]: Problem identifying calling URL in PHP script
Post by: steveeh131047 on March 19, 2008, 03:04:32 PM
Nibbler,

Perfect! A global declaration fixed it. Guess I need to take some more PHP lessons :)

Thanks for your help.

Steve