HostMyApple Posted January 24, 2019 Share Posted January 24, 2019 Hello, I am trying to add the IP address for a customers service in the clientareaproducts.tpl page I have added a column for IP address on this page however I am unable to determine the variable needed to get the IP address for each service to show up. I have this working when a customer clicks into the service (clientareaproductdetails.tpl) with the variable {$dedicatedip} however that variable does not work on the clientareaproducts.tpl since that page is trying to list ever product a customer has so multiple IPs should be displaying if they have multiple services I have tried {$service.dedicatedIp} and {$dedicatedip} to no avail. My trouble is when i have a customer and they go to My Products and Services if they have many servers they might see 10+ services and not know which is which because they cant see the IP for each service. They only see the service description price, next due date and status. Please let me know if anyone has any idea here. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 24, 2019 Share Posted January 24, 2019 19 minutes ago, HostMyApple said: Please let me know if anyone has any idea here. using {$service.server.ipaddress} might be an option - but if you add {debug} to the template, you'll get a popup window of available variables... if you can find what you want in there, you're in business... if not, you'd have to modify the array with a hook. 0 Quote Link to comment Share on other sites More sharing options...
HostMyApple Posted January 24, 2019 Author Share Posted January 24, 2019 Hi Brian, Thanks for the reply. I tried {$service.server.ipaddress} and it's simply returning the IP address of my provisioning server and not the customers assigned product IP address. I checked {debug} and the only IP I see listed is still my provisioning server. I found this post here of someone trying to do the same thing but on an invoice tpl: https://stackoverflow.com/questions/49162313/display-dedicated-ip-into-viewinvoice-tpl-and-invoicepdf-tpl-in-whmcs?noredirect=1&lq=1 This seems to be along the lines of what you were mentioning of using a hook to pull the IP. Also I found a previous post that you made which I also tried and didn't seem to work: It seems to be having trouble with the PHP section of it because when i paste that in the template under "foreach from=$services item=service" the entire page dies and only loads white. Any help you can offer on this would be greatly appreciated. I've attempted to tackle this for several years now and i'm just not great with PHP (pretty terrible actually). If you have any idea's please let me know, I really do appreciate it 🙂 Thank You 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 25, 2019 Share Posted January 25, 2019 20 hours ago, HostMyApple said: This seems to be along the lines of what you were mentioning of using a hook to pull the IP. it's along the lines... 20 hours ago, HostMyApple said: Also I found a previous post that you made which I also tried and didn't seem to work that's the problem with quoting threads that are 4+ years old... times change and the required coding changes. 🙂 I suspect I could make that old code work if I had to, but it would have to be totally rewritten. 20 hours ago, HostMyApple said: It seems to be having trouble with the PHP section of it because when i paste that in the template under "foreach from=$services item=service" the entire page dies and only loads white. {php} was removed from Smarty years ago and whilst you can still use it in WHMCS (for now), doing so is frowned upon and best avoided. 20 hours ago, HostMyApple said: Any help you can offer on this would be greatly appreciated. I've attempted to tackle this for several years now and i'm just not great with PHP (pretty terrible actually). to do the equivalent of the above code as a hook for the Products/Services page would be... <?php # Add Dedicated IP To The Services Array Hook # Written by brian! use Illuminate\Database\Capsule\Manager as Capsule; function clients_services_add_dedicatedip_hook($vars) { $client = Menu::context('client'); $services = $vars['services']; foreach($services as $key => $service) { $dedicatedip = Capsule::table('tblhosting')->where('userid',$client->id)->where('id',$service['id'])->value('dedicatedip'); if ($dedicatedip) { $services[$key]['dedicatedip'] = $dedicatedip; } } return array("services" => $services); } add_hook("ClientAreaPageProductsServices", 1, "clients_services_add_dedicatedip_hook"); ?> this basically takes the $services Smarty array from the Products/Services page, loops though it and checks if the current service has a dedicated IP value stored for it - if so, it adds an entry to the array, if not, it doesn't... and then returns the updated array back to the template. what that should give you is a variable in the template that you can use anywhere inside the foreach loop - {$service.dedicatedip}... in the template, you could possibly use it this way... {if $service.dedicatedip}<br />{$service.dedicatedip}{/if} but if it exists for a service, the {$service.dedicatedip} variable will be there for you to use however/wherever you want to. 2 Quote Link to comment Share on other sites More sharing options...
HostMyApple Posted January 25, 2019 Author Share Posted January 25, 2019 This worked perfectly Brian! Thank You so much! 🙂 0 Quote Link to comment Share on other sites More sharing options...
unknownsolo Posted November 24, 2020 Share Posted November 24, 2020 This no longer works - any chance someone has an update to display dedicated IP in product list? @brian! I would really appreciate your help 🙂 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 25, 2020 Share Posted November 25, 2020 19 hours ago, unknownsolo said: This no longer works - any chance someone has an update to display dedicated IP in product list? on which WHMCS version? I just tried in v8.0.4 and it works fine.... did you remember to add the suggested template change ?? there would be ways to do this without making the template change required, but the above hook still does what it's supposed to. 0 Quote Link to comment Share on other sites More sharing options...
unknownsolo Posted November 25, 2020 Share Posted November 25, 2020 Thank you for getting back to me. I am on 8.0.4 and have tested this on a fresh install with fresh six template. I created a file called show_ip.php under includes/hooks/ as follows: and edited "clientareaproducts.tpl like so: But I get nothing: These two test products do have IPs in the dedicated IP field. The dedicated IP also doesn't show in the {debug} page. Not sure what I am not doing correctly. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 26, 2020 Share Posted November 26, 2020 if you examine the tblhosting database table, are the dedicated IP values in there ? 0 Quote Link to comment Share on other sites More sharing options...
VNIT Posted December 12, 2020 Share Posted December 12, 2020 anyone tell me how to add dedicate IP to related product in client submit ticket / 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted December 17, 2020 Share Posted December 17, 2020 On 12/12/2020 at 15:51, VNIT said: anyone tell me how to add dedicate IP to related product in client submit ticket / you could use a hook to append the values in the related services dropdown to include a DIP value - e.g looping through the array, and where it's a service, checking if a DIP value is available and appending the name of the related service to include it. 1 Quote Link to comment Share on other sites More sharing options...
VNIT Posted October 13, 2021 Share Posted October 13, 2021 thank you 0 Quote Link to comment Share on other sites More sharing options...
Dineshkm Posted April 15 Share Posted April 15 On 17/12/2020 at 8:07 PM, brian! said: you could use a hook to append the values in the related services dropdown to include a DIP value - e.g looping through the array, and where it's a service, checking if a DIP value is available and appending the name of the related service to include it. This is not working for me.. I still get the "-" after domain where as the database have DIP for the product. 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.