running custom php scripts running custom php scripts
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

running custom php scripts

Started by Fed, November 07, 2006, 12:59:56 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Fed

hello guys
I've spent more than half an hour searching the forums for how to run custom php code inside a template but it seems I'm not able to find anything regarding this...

I obviously tried adding <?php myscripthere ?> in the template but...

how can I have my php code executed inside coppermine?

sorry for the "asked 1000 times" question but I couldn't find any thread discussing this ???

if it's useful I'm running cpg 1.4

Sami

If you want to run it on all pages try custom header or custom footer if you want it on index only try anycontent.php
‍I don't answer to PM with support question
Please post your issue to related board

Joachim Müller

Just for clarification: you can't have PHP in themes/yourtheme/template.html, no matter what you do. Do as Sami suggested, or come up with a custom token and then modify themes/yourtheme/theme.php as well. However, you'll need some coding skills to accomplish this, so you better go for one of the options Sami suggested.

Fed

Quote from: GauGau on November 07, 2006, 07:14:31 AM
Just for clarification: you can't have PHP in themes/yourtheme/template.html, no matter what you do. Do as Sami suggested, or come up with a custom token and then modify themes/yourtheme/theme.php as well. However, you'll need some coding skills to accomplish this, so you better go for one of the options Sami suggested.
I solved using a custom token
the themes.inc.php, in the function pageheader() I added my php code that stores the value in a variable named $i_t_user then added
'{USERSONLINE}' => $i_t_user,
to the $template_vars array then put {USERSONLINE} in the template and it's working smooth
I'm not sure if this is what you meant

thanks guys

Sami

Never edit theme.inc.php , copy the function you want to change (pageheader() in your case) from themes/sample/theme.php to themes/your-theme/theme.php  instead and mod it the way you want to
‍I don't answer to PM with support question
Please post your issue to related board

Fed

Quote from: Sami on November 07, 2006, 11:11:00 AM
Never edit theme.inc.php , copy the function you want to change (pageheader() in your case) from themes/sample/theme.php to themes/your-theme/theme.php  instead and mod it the way you want to
ah ok I didn't know theme.inc.php shouldn't be touched (I was sceptical on editing it because it might have been a problem at the time of upgrading to a newer version)
if I edit /mythere/theme.php, how does CPG know that should use the pageheader() in theme.php and not the one in theme.inc.php? is this a coppermine default behaviour?

thanks again :)

Nibbler

Your custom theme.php is loaded up first. Then themes.inc.php is loaded and defines any functions that are not already defined by your custom theme.