Alex Borsody
Alex Borsody

Reputation: 2040

Where are Smarty Template Variables Defined?

I am working on a program with a Smarty template, where do the $variables come from as I see no file they are pulling from in the html. Where do I find these variables so I can edit them. Similarly in Drupal, there are different variables available in different TPL files, because I see no includes, where is this information coming from/being pulled from, I know this is a noob question.

Upvotes: 3

Views: 947

Answers (3)

Paul DelRe
Paul DelRe

Reputation: 4039

The variables are set in the PHP files that instantiate the Smarty object. You can find them by searching for the assign() calls. Since Smarty template do not (should not) contain PHP code in them, you won't see include calls.

Upvotes: 0

Mat
Mat

Reputation: 6725

The variables are defined in the PHP script files that use the templates. Look for lines like

$smarty->assign( "var_name", $value );

Upvotes: 0

webbiedave
webbiedave

Reputation: 48887

Smarty variables are set in the business logic via $smarty->assign('firstName', 'Mike');

http://www.smarty.net/docsv2/en/api.assign

You can check out the Smarty.class.php source to find out where they are actually stored (they're in a member variable named $tpl_vars).

Upvotes: 1

Related Questions