Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Smarty autobind PHP variables to Smarty variables

Tags:

php

smarty

In my smarty code I write a lot of code such as this:

$smarty->assign('priorityList', $priorityList);
$smarty->assign("groupview", $groupview);
$smarty->assign('processList', key($processList));
$smarty->assign('taskList', $taskList);

See how annoying it has become; I use the same name for Smarty variables and PHP variables, and yet I need to waste time and typing to connect the two.

Is there any option that I can set, so that the smarty variables will be automatically mapped to the PHP variables with the same name?

like image 867
Graviton Avatar asked Dec 03 '22 14:12

Graviton


1 Answers

Use compact.

$smarty->assign(compact('priorityList', 'groupview', 'processList', 'taskList'));
like image 176
gnud Avatar answered Dec 11 '22 20:12

gnud