1

I am using the smarty templating system for php. I have the following within a .tpl file:

 <a href=\"{/literal}/view/{$tablename}/

where $tablename is a php variable defined in the php file that calls the .tpl

$tablename = 'string';

However running the script only

href="/view//"

is visible. What am I doing wrong?

2 Answers 2

6

This

$tablename = 'string';

is not enough to populate a variable into Smarty.

You need to use

$Smarty->assign("tablename", $tablename);

$Smarty being your initialized Smarty object, of course.

Sign up to request clarification or add additional context in comments.

Comments

2

Are you assigning to variable to the smarty instance? e.g with assign()?

 $smarty->assign('tablename', $tablename);

See also the manual page on assigning variables from PHP

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.