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
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
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.
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
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
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 :)
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.