coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 themes/skins/templates => Topic started by: steveeh131047 on March 22, 2008, 09:53:11 AM

Title: [Solved]: Checking which theme in PHP
Post by: steveeh131047 on March 22, 2008, 09:53:11 AM
I'm generating dynamic content with some PHP invoked through {CUSTOM_HEADER}. The generated content needs to be slightly different between two different themes. Is there any cpg variable the PHP can check to know which theme is running?
Title: Re: Checking which theme in PHP
Post by: Sami on March 22, 2008, 10:30:53 AM
There is a global array ($CONFIG) that gets its values under include/init.inc.php
You can find theme value by checking this:

$CONFIG['theme']
Title: Re: Checking which theme in PHP
Post by: steveeh131047 on March 22, 2008, 10:44:17 AM
Sami, I'm relatively new to PHP.

Just to test the variable I tried:

global $CONFIG['theme'];
echo $CONFIG['theme'];

but I got a syntax error.
Have I missed something obvious?
Title: Re: Checking which theme in PHP
Post by: steveeh131047 on March 22, 2008, 10:47:11 AM
Sami, Now OK.

Just realised the global declaration should have been:

global $CONFIG;

Thanks for your help
Title: Re: Checking which theme in PHP
Post by: Sami on March 22, 2008, 10:53:14 AM
Yes ,To use a global variable under a function you need to declare it as a global under that function
for more info check this :
http://us2.php.net/global
Title: Re: [Solved]: Checking which theme in PHP
Post by: steveeh131047 on March 22, 2008, 11:24:01 AM
Sami,

Yes, I remembered I needed the global declaration, but I hadn't realised I needed to delare the array name rather than just the specific array index. With you guys' help and support it's all working nicely now.

My original implementation of CPG is at:
http://www.miltonmalsorhistory.org.uk/gallery/index.php?theme=mmhs

but my new theme integrates it into the site better:
http://www.miltonmalsorhistory.org.uk/gallery/index.php?theme=mmhs2

I've still got some "tidying up" to do, but it should all be "downhill" from here.

Thanks again for a great script.