Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: [Solved]: Checking which theme in PHP  (Read 3754 times)

0 Members and 1 Guest are viewing this topic.

steveeh131047

  • Supporter
  • Coppermine frequent poster
  • ****
  • Offline Offline
  • Posts: 217
[Solved]: Checking which theme in PHP
« 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?
« Last Edit: March 22, 2008, 10:55:25 am by Sami »
Logged

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: Checking which theme in PHP
« Reply #1 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:
Code: [Select]
$CONFIG['theme']
Logged
‍I don't answer to PM with support question
Please post your issue to related board

steveeh131047

  • Supporter
  • Coppermine frequent poster
  • ****
  • Offline Offline
  • Posts: 217
Re: Checking which theme in PHP
« Reply #2 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?
Logged

steveeh131047

  • Supporter
  • Coppermine frequent poster
  • ****
  • Offline Offline
  • Posts: 217
Re: Checking which theme in PHP
« Reply #3 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
Logged

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: Checking which theme in PHP
« Reply #4 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
Logged
‍I don't answer to PM with support question
Please post your issue to related board

steveeh131047

  • Supporter
  • Coppermine frequent poster
  • ****
  • Offline Offline
  • Posts: 217
Re: [Solved]: Checking which theme in PHP
« Reply #5 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.
Logged
Pages: [1]   Go Up
 

Page created in 0.026 seconds with 16 queries.