JulianvSchijndel Posted November 24, 2019 Share Posted November 24, 2019 Hey, I'm using the GetLTDPricing API en I edited it a litte bit en this is my output: {"result":"success","currency":{"id":"1","code":"EUR","prefix":"\u20ac","suffix":" EUR","format":"1","rate":"1.00000"},"pricing":{"nl":{"categories":["ccTLD","Geography"],"addons":{"dns":true,"email":false,"idprotect":true},"group":"","register":{"1":"5.95"},"renew":{"1":"5.95"},"grace_period":{"days":0,"price":"\u20ac0.00 EUR"},"redemption_period":null},"be":{"categories":["ccTLD","Geography"],"addons":{"dns":true,"email":false,"idprotect":true},"group":"","register":{"1":"8.00"},"renew":{"1":"8.00"},"grace_period":{"days":0,"price":"\u20ac0.00 EUR"},"redemption_period":null},"com":{"categories":["gTLD","Popular"],"addons":{"dns":true,"email":false,"idprotect":true},"group":"","register":{"1":"10.00"},"renew":{"1":"10.00"},"grace_period":{"days":30,"price":"\u20ac0.00 EUR"},"redemption_period":null}}} Now i wanted to put that into a costum .tpl file but i don't know how. I want it in this way in my costum .tpl file: <div class="col-sm-6 col-md-4"> <div class="domain-box d-color1"> <div class="title">THE EXTENTIES (EXAMPLE: .nl/.be/.com)</div> <div class="price">DOMAIN REGISTER PRICE WHIT CURRENCY</div> <div class="details"><b>PRICE FOR 1 YEAR</b></div> <div class="link"> <a class="register-button" href="cart.php?a=add&domain=register">Registreer</a> </div> </div> </div> If needed also my API: <?php /* * API om prijzen van domeinnaam extenties op te halen * Hopelijk werkt dit anders wordt ik gek * Effe kijken en hier gaan we dan he */ // Onze URL ah niffauw $url = "https://juulict.nl"; // API username en password. $username = "wwnQCCnPDx6zKQbEdNyMsLU5GZWZNZTd"; $password = "QOZWOvVuNo2rvJSQSjJRN6oeHKDAeC2n"; // Het posten van iets yaaayy $postData = array( 'action' => 'GetTLDPricing', 'username' => $username, 'password' => $password, 'currencyid' => '1', 'responsetype' => 'json' ); // Het roepen van de api, hopen dat die werkt met z'n irritante *. $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url . '/includes/api.php'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData)); $response = curl_exec($ch); if (curl_error($ch)) { die('Kan niet verbinden: ' . curl_errno($ch) . ' - ' . curl_error($ch)); } curl_close($ch); // Omzetten in JSON file ah neef print $response; I really hope someone can help me with this. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 25, 2019 Share Posted November 25, 2019 Hi Julian, 16 hours ago, JulianvSchijndel said: Now i wanted to put that into a costum .tpl file but i don't know how. I want it in this way in my costum .tpl file: you would need a hook, probably ClientAreaPage, to take the results of the API and pass it back to the template in a variable that the template can output. FWIW, if all you want to do is output the TLD pricing table in the template, it might be easier to use the Domain Pricing Table Data Feed. https://docs.whmcs.com/Data_Feeds#Domain_Pricing_Table 0 Quote Link to comment Share on other sites More sharing options...
JulianvSchijndel Posted November 25, 2019 Author Share Posted November 25, 2019 Hi Brain!, Thanks for you’re answer. I don’t know how to make that hook. I tried the feed but i need it in a custom template, i tried editing the feed but it doesn’t work.. Can you have a example how to do it? 0 Quote Link to comment Share on other sites More sharing options...
JulianvSchijndel Posted November 25, 2019 Author Share Posted November 25, 2019 Hi, This problem is solved. This is how i did it. I made a API called /aadomainlist.php with the code: ?php /* * API om prijzen van domeinnaam extenties op te halen * Hopelijk werkt dit anders wordt ik gek * Effe kijken en hier gaan we dan he */ // Onze URL ah niffauw $url = "HTTPS://LINKTOWHMCS.COM"; // KEK NEN EURO AAAAAHHHHHHHH (gekke error reporting) ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); // API username en password. $username = "API_IDENTIFER"; $password = "API_PASSWORD"; // Het posten van iets yaaayy $postData = array( 'action' => 'GetTLDPricing', 'username' => $username, 'password' => $password, 'currencyid' => '1', 'responsetype' => 'json' ); // Het roepen van de api, hopen dat die werkt met z'n irritante *. $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url . '/includes/api.php'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData)); $response = curl_exec($ch); curl_close($ch); print_r($response); Then in the custom template: {php} $output = file_get_contents('https://juulict.nl/includes/api/aadomainlist.php'); $response = json_decode($output); foreach ($response->pricing as $price => $value) { print_r($price.'<br>'); $var = '1'; echo $value->register->$var.'<br>'; } {/php} So this is for the people who need it. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 26, 2019 Share Posted November 26, 2019 17 hours ago, JulianvSchijndel said: I don’t know how to make that hook. you could have searched for clientareapage and you would have found a lot of working example hooks... 👀 to return the TLD pricing to the template, literally takes no more than 2 lines of PHP code inside a hook... maybe 3 if you need it to work only on one specific page. 🙂 then in the custom Smarty template... {foreach $domainpricing['pricing'] as $tld => $price} {$tld} : {$price['register']['1']}<br> {/foreach} .. which gives you a list of tlds with their 1 yr registration price (obviously additional formatting can be added in the template)... 17 hours ago, JulianvSchijndel said: I tried the feed but i need it in a custom template data feeds should work on any page, whether inside of WHMCS or outside on an external site... 17 hours ago, JulianvSchijndel said: i tried editing the feed but it doesn’t work.. I can see that you've modified the domainpricing.php feed output... ... so it works, it just needs additional formatting within it. similarly, if you (or anyone else!) just wanted to show your one year registration price for .nl, you could use.. <script language="javascript" src="https://juulict.nl/feeds/domainprice.php?tld=.nl&type=register&regperiod=1&format=1"></script> ... in your custom template, and it would output... €5.95 EUR ... so these feeds should work on your site on any page. 🙂 11 hours ago, JulianvSchijndel said: So this is for the people who need it. that's not a good solution for a number of reasons - not the least of which is that {php} got deprecated from Smarty years ago... Quote IMPORTANT NOTICE {php} tags are deprecated from Smarty, and should not be used. Put your PHP logic in PHP scripts or plugin functions instead. the only way your solution works is that in v6, WHMCS enabled a temporary solution to allow them... https://docs.whmcs.com/Templates_and_Custom_PHP_Logic Quote As of Smarty 3, support for the {php} block has been removed, and we are only providing legacy support to ease the transition for developers and users who work with our platform and rely on this functionality. In WHMCS 6.0 and later, a backwards compatibility Security setting "Allow Smarty PHP Tags" has been introduced in Setup > General Settings > Security which must be checked to enable the use of PHP tags. This setting defaults to Off, and may be removed in a future versions. that was posted over 4 years ago when v6 was launched - so it's only a matter of time before the {php}option is permanently removed... possibly as soon as v8 next year. it's been a long time since anyone posted code here that required {php} in the template to work. also, it's worth noting that if you are using Six, then you should have a separate domain pricing page anyway... https://juulict.nl/domain/pricing/ https://juulict.nl/index.php?rp=domain/pricing ... but the actual URL you can use will depend on your Friendly URL settings. 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.