|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
David Webb Smarty n00b
Joined: 10 Mar 2016 Posts: 1
|
Posted: Thu Mar 10, 2016 4:33 pm Post subject: Complex multi array in smarty3 |
|
|
Hello,
I have a small problem and hope you can help me...
This Code in PHP works fine:
Code: | $steamData = file_get_contents('http://steamcommunity.com/profiles/$ID/inventory/json/730/2');
$data = json_decode($steamData, true);
$items = $data['rgInventory'];
foreach($items as $key => $item){
$item = $data['rgDescriptions'][$item['classid'] . '_' . $item['instanceid']]['name'].'<img src="http://steamcommunity-a.akamaihd.net/economy/image/'.$data['rgDescriptions'][$item['classid'] . '_' . $item['instanceid']]['icon_url'].'" /><br />';
} |
But I dont know, how to do this foreach with Smarty, i have splitted the code like this:
Code: | functions.php
public function getPartnerInventory($SteamID64) {
$url = 'https://steamcommunity.com/profiles/'.$SteamID64.'/inventory/json/730/2';
$json = file_get_contents($url);
$data = json_decode($json, true);
return $data;
} |
Code: | inventory.php
$data = $Class->getPartnerInventory($this->User['UserSteamID64']);
$items = $data['rgInventory'];
$Smarty->assignGlobal('data', $data);
$Smarty->assignGlobal('items', $items);
$Smarty->display('myinventory.tpl'); |
And now I need the foreach in Smarty, I tried a few things, but nothing works. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|