gamestuff Posted March 26, 2016 Share Posted March 26, 2016 Hey there, I hate to have to ask here, but after much trial and error I just am not getting this new query system and I really find a huge lack of examples so far so I am asking for help. Basically what I want to do is simple: I have a field called "Slot_Number" in the 'tblhosting' table, which I need to display on the Product Details page. This query will need to search for the current $serviceid, and based on that $serviceid pull the "slot_number" value and pass it as a variable I can display/play with. In Mysql I would do something like this: SELECT `slot_number` FROM `tblhosting` WHERE `id` = $serviceid How do I go about selecting a value from a query in this new system and then passing it as a variable to be used? Thanks! 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted March 26, 2016 Share Posted March 26, 2016 When you say "new system" you mean DB Manager right? $selectSlotNum = Capsule::table("tblhosting")->where("id", "=", $serviceid)->get(); echo $selectSlotNum[0]->slot_number; 0 Quote Link to comment Share on other sites More sharing options...
gamestuff Posted March 26, 2016 Author Share Posted March 26, 2016 Thanks for the direction, So my understanding is I need to put this into a hook file? I have taken your php and put it into a file called showSlot.php <?php use Illuminate\Database\Capsule\Manager as Capsule; function hook_showSlot($vars){ $selectSlotNum = Capsule::table("tblhosting")->where("id", "=", $serviceid)->get(); echo $selectSlotNum[0]->slot_number; } add_hook("ClientAreaProductDetails", 1, "hook_showSlot"); How do I now call the slot number to display on the page clientareaproductdetails.tpl? Also, is the hook called before or after the page is loaded? I'm using the $serviceid variable based on the variables available from the {debug} command on this particular page, but if the hook is loaded first it probably wouldn't have this variable accessible? I don't even know if this variable is accessible anyways. 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted March 26, 2016 Share Posted March 26, 2016 modify your actionhook function like below: <?php use Illuminate\Database\Capsule\Manager as Capsule; function hook_showSlot($vars){ $selectSlotNum = Capsule::table("tblhosting")->where("id", "=", $vars['serviceid'])->get(); return array("slotnumber" => $selectSlotNum[0]->slot_number); } add_hook("ClientAreaPage", 1, "hook_showSlot"); - - - Updated - - - modify your actionhook function like below: <?php use Illuminate\Database\Capsule\Manager as Capsule; function hook_showSlot($vars){ if ($vars['action']!=="productdetails"){ return array(); } $selectSlotNum = Capsule::table("tblhosting")->where("id", "=", $vars['serviceid'])->get(); return array("slotnumber" => $selectSlotNum[0]->slot_number); } add_hook("ClientAreaPage", 1, "hook_showSlot"); then place this variable {$slotnumber} in /templates/your-template/clientareaproductdetails.tpl where you need it to be displayed 0 Quote Link to comment Share on other sites More sharing options...
gamestuff Posted March 26, 2016 Author Share Posted March 26, 2016 Perfect, works like a charm! Thank you so much! 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.