Note de ce sujet :
  • Moyenne : 0 (0 vote(s))
  • 1
  • 2
  • 3
  • 4
  • 5

Module news
#13

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]
Répondre


Messages dans ce sujet

Atteindre :


Utilisateur(s) parcourant ce sujet : 1 visiteur(s)