PHP Variable Problem

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
nick
Forum Members
Forum Members
Posts: 10
Joined: Thu Apr 20, 2006 2:35 pm

PHP Variable Problem

Post 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!
cyberman

Re: PHP Variable Problem

Post 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');
nick
Forum Members
Forum Members
Posts: 10
Joined: Thu Apr 20, 2006 2:35 pm

Re: PHP Variable Problem

Post 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 />
cyberman

Re: PHP Variable Problem

Post 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} ...
nick
Forum Members
Forum Members
Posts: 10
Joined: Thu Apr 20, 2006 2:35 pm

Re: PHP Variable Problem

Post 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.
cyberman

Re: PHP Variable Problem

Post 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;
Post Reply

Return to “CMSMS Core”