View Full Version : Assigning array to smarty variables
IntoRain
05-31-2014, 12:04 AM
Hi. I've been changing the theme around now that Kyttias made it possible to use bootstrap, and I wanted to know where I could assign an array to the smarty variables. I found a way to add native variables through the frame class, but it seems hashmaps don't take arrays :(
Hall of Famer
06-01-2014, 01:14 PM
Well standard smarty array assignment works like this:
$myArray = array('no' => 10, 'label' => 'Peanuts'); $smarty->assign('foo',$myArray);
In this script I made a class called Template inheriting the parent Smarty class, and the assign method still works. The template object is stored inside the mysidia object from registry, you can access it like this:
$mysidia = Registry::get("mysidia");
$mysidia->template->assign('arrayname', $array);
IntoRain
06-01-2014, 01:31 PM
OOoh! Thank you! I've been messing around with the class_frame render() function and arrays didn't work obviously xD I've been doing it wrong all along xD Thank you! That solves it! ^^
Hall of Famer
06-03-2014, 03:06 PM
Glad I can be of any help. ^^
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.