[Solved] How to pass array from php to javascript using smarty 3? [closed]

In php: $names = [‘jim’, ‘lucy’]; $smarty->assign(‘names’, $names); In javascript, var arr = {$names|json_encode}; Notice: If you changed your smarty default_modifiers to array(‘escape:”html”‘), use var arr = {$names|json_encode nofilter}; to make everything work. Good luck. solved How to pass array from php to javascript using smarty 3? [closed]

[Solved] how assign mysql rows in smarty php?

From the manual: http://www.smarty.net/crash_course include(‘Smarty.class.php’); // create object $smarty = new Smarty; // assign some content. This would typically come from // a database or other source, but we’ll use static // values for the purpose of this example. $smarty->assign(‘name’, ‘george smith’); $smarty->assign(‘address’, ’45th & Harris’); // display it $smarty->display(‘index.tpl’); You need to call $smarty->assign() … Read more

[Solved] Get date for past weekday with Smarty

This is logic that you would normally put inside your PHP script, not smarty. Try something like this: empty($_GET[‘day’]) ? $day = date(‘l’) : $day = $_GET[‘day’]; $date = strtotime(“last {$day}”); echo “News from “.date(“l, F j”, $date); This script assumes that you pass the day as a GET parameter, for example index.php?day=monday. You can … Read more

[Solved] Apply a smarty modifier to JS?

I’m afraid you cannot operate on JavaScript variables to get their value. Smarty can operate only on its variables – they either come from PHP or are set in Smarty. JavaScript variable cannot be set anyway to Smarty so you cannot do it. But in case you want to assign PHP/Smarty variable with modifier to … Read more