17/05/2010, 15:03:03
How to provide variables from a UDT to your page/template
Sometimes you need to provide calculated or processed information via PHP variables from a UDT to a page or template. To do this add a new UDT and call it e.g. "Var" and fill in the code below
global $gCms;
$smarty = &$gCms->GetSmarty();
$foo= "test"; // Variable you want to provide
$smarty->assign('foo', $foo); // make variable "foo" visible for CMSms
Now you are able to use the variable in pages or templates via Smarty:
{Var} {* Call the UDT "Var" before using its variable(s) *}
<p>The content of the variable "foo" is {$foo}.</p>
Output:
The content of the variable "foo" is test.
[source]
Sometimes you need to provide calculated or processed information via PHP variables from a UDT to a page or template. To do this add a new UDT and call it e.g. "Var" and fill in the code below
global $gCms;
$smarty = &$gCms->GetSmarty();
$foo= "test"; // Variable you want to provide
$smarty->assign('foo', $foo); // make variable "foo" visible for CMSms
Now you are able to use the variable in pages or templates via Smarty:
{Var} {* Call the UDT "Var" before using its variable(s) *}
<p>The content of the variable "foo" is {$foo}.</p>
Output:
The content of the variable "foo" is test.
[source]