Jomart_123 Posted November 25, 2017 Share Posted November 25, 2017 im pulling data from DB to pass them to smarty clientareahome.tpl from a hook <?php use Illuminate\Database\Capsule\Manager as Capsule; function hook_pullingCustomerData($vars){ $customerID = $_SESSION['uid']; $hostingData = Capsule::table('tblhosting') ->where('userid', $customerID) ->get(); return array("customerHostingData" => $hostingData); } add_hook("ClientAreaPage", 1, "hook_pullingCustomerData"); on the template file i have this {$customerHostingData.domain} im getting an empty space, instead of the domain name, Any ideas??? Link to comment Share on other sites More sharing options...
brian! Posted November 26, 2017 Share Posted November 26, 2017 23 hours ago, Jomart_123 said: im getting an empty space, instead of the domain name, Any ideas??? it's because $customerHostingData will be an array and not a variable - so the usual display method would be a foreach loop in the template (you'll find many examples of how to do that already in the templates). <?php use Illuminate\Database\Capsule\Manager as Capsule; function hook_pullingCustomerData($vars){ $client = Menu::context('client'); $hostingData = Capsule::table('tblhosting') ->where('userid', $client->id) ->get(); $encodedata = json_encode($hostingData); $decodedata = json_decode($encodedata, true); return array("customerHostingData" => $decodedata); } add_hook("ClientAreaPageHome", 1, "hook_pullingCustomerData"); you could access the array values directly, e.g the first domain would be {$customerHostingData.0.domain}, but generally you would loop through the array. also, adding {debug} to the end of the template, will generate a popup window of available variables and arrays - just remember to remove the code from the template, when you've finished. Link to comment Share on other sites More sharing options...
Recommended Posts