Jump to content

Calling the function with parameter from controller to template


Recommended Posts

how can you do this?

 

EXAMPLE:

 

in my PHP FILE

 

public function getSum($num1,$num2)

{
return $num1+$num2;

}

 

$data->assign(array(        
       'sum' => $this->getSum($num1,$num2)

));

 

 

TEMPLATE FILE:

In my template file, how can I call it?

 

I tried the following:

>>{$sum('2','5')}   // should display 7

 

>>{assign var=num1 value="1"}
>>{assign var=num2 value="5"}

>>{$sum($num1,$num2)}   // should display 7

 

Nothing seems to work.

Link to comment
Share on other sites

×
×
  • Create New...