Page 1 of 1

PHP Variable Problem

Posted: Fri Nov 09, 2007 7:43 am
by nick
Hi,

I'm trying to integrate a PHP page with CMSMS 1.2, but the PHP scripts are acting differently once they're integrated. I believe the problem is that variable defined in one UDT are not available for following UDTs. The page works great on the same server without CMSMS. So here's a piece of the code:

Code: Select all

{require_people}
{literal}
<__script__ type="text/javascript" src="js/mootools.js"></__script>
<__script__ type="text/javascript">
var transspeed={/literal}{gallery_trans}{literal};
the UDT {require_people} contains:

Code: Select all

require_once "config_people.php";
require_once "getfolders.php";
and config_people.php contains:

Code: Select all

$transitionspeed="500";
and the UDT {gallery_trans} contains:

Code: Select all

echo "$transitionspeed";
But {gallery_trans} produces no results! The only way I can get

Code: Select all

echo "$transitionspeed";
to work is if I include it in the {require_people} tag. But I need variables from the original {require_people} to be available for all following php scripts on the page.

Thanks for your help!

Re: PHP Variable Problem

Posted: Fri Nov 09, 2007 9:45 am
by cyberman
Try this

{require_people}

Code: Select all

require_once "config_people.php";
require_once "getfolders.php";
$smarty->assign('tspeed', $transitionspeed);
{gallery_trans}

Code: Select all

echo $this->get_template_vars('tspeed');

Re: PHP Variable Problem

Posted: Sat Nov 10, 2007 2:55 am
by nick
thanks for your quick reply. although now i get the following error where {gallery_trans} is called:

Code: Select all

<b>Fatal error</b>:  Call to a member function on a non-object in 
<b>/home/fotograf/www/www/lib/content.functions.php(669) :
 eval()'d code</b> on line <b>1</b><br />

Re: PHP Variable Problem

Posted: Mon Nov 12, 2007 8:16 am
by cyberman
cyberman wrote: {gallery_trans}

Code: Select all

echo $this->get_template_vars('tspeed');
In cause of assigning $transitionspeed to Smarty as $tspeed it should be possible too to access it via {$tspeed} ...

Re: PHP Variable Problem

Posted: Mon Nov 12, 2007 6:24 pm
by nick
thanks, the above works for calling the variable into the page.

but... i still need to use the variable in other php scripts on the page and i don't know how to call it without getting the error i described in my last post. using {$tspeed} does not work in the php script either.

Re: PHP Variable Problem

Posted: Tue Nov 13, 2007 10:26 am
by cyberman
cyberman wrote: {gallery_trans}

Code: Select all

echo $this->get_template_vars('tspeed');
I'm sorry ... my fault ... try this

Code: Select all

global $gCms;
$smarty =& $gCms->GetSmarty();
$tspeed = $smarty->get_template_vars('tspeed');
echo $tspeed;