Jump to content

Find domain tld in client area - WHMCS V6


Recommended Posts

Hello

 

Am in the process of upgrading to V6.3 from V5 and making changes to our default V5 template. I had an IF statement I was using to display info in the client area specific to a tld

 

if $tld eq "ie"

 

Now it seems the variable $tld is no longer being used in V6 , am I correct ? I stuck a {debug} at the top of the page and its not listing $tld or $sld as an available option anymore.

 

Any ideas how I can obtain that info in V6 easily without having to write a hook ?

 

TIA

Martin

Link to comment
Share on other sites

Hi Martin,

 

which clientarea page are you looking at to do this in ? there are many pages to choose from and some might have a usable variable, others not! :)

 

e.g., if it was clientareadomaindetails.tpl, then you'd have access to $domain and from that you could use Smarty to get the TLD and display the appropriate message.

Link to comment
Share on other sites

Hi Martin,

 

sorry - from your reply, I got the impression that you knew how to do it! :oops:

 

the quick way, if this is for an Irish domain, would be to simply check if the domain contains '.ie' - unless you're offering 4th level domains, or something where '.ie' could appear other than the end, then this should be sufficient...

 

{if $domain|strstr:'.ie'} message {/if}

for other TLDs, you might need to specifically check that the substring is at the end of the variable, and not just anywhere in the variable.

 

for your purpose, what you might find more convenient is to split $domain into $sld and $tld - that should allow you to use your previous {if} code from v5.

 

{assign domsearch $domain|strpos:"."}
{assign sld $domain|substr:0:$domsearch} 
{assign tld $domain|substr:($domsearch+1)}

the above Smarty code is written for v6 (using Smarty3), it wouldn't necessarily work in v5 (using Smarty2) - so others wanting to do this in v5, would need to use the code I posted in the thread below.

 

http://forum.whmcs.com/showthread.php?107379-using-php-in-domainoptions-tpl&p=440938#post440938

 

you'll now have two variables that you can use on the domaindetails page, {$sld} and {$tld} - so you should be able to use your previous code...

 

{if $tld eq "ie"} message {/if}

hope that helps! :idea:

Link to comment
Share on other sites

Hi Brian

 

Thanks for this , and sorry for confusion . This appears to be working which is great but I am getting an additional error now

 

Fatal error: Using $this when not in object context in /var/www/vhosts/mydevdomain/httpdocs/vendor/smarty/smarty/libs/SmartyBC.class.php(464) : eval()'d code on line 8

 

In my block of code I am referencing $this

 

$domainid = $this->_tpl_vars['domainid'];

$domainname = $this->_tpl_vars['domain'];

 

Is there a replacement variable for $this ?

 

Thanks again for your help,

Regards

Martin

Link to comment
Share on other sites

Hi Martin,

 

I might need to see you entire code - but I get the impression that you're trying to do this in PHP i.e within {php} tags rather than purely in Smarty. :roll:

 

at some point in the future, using {php} tags won't be an option in WHMCS - so if you can do it only using Smarty and drop the {php} tags, now would be a good time to start. :idea:

 

however, if you have to, check out the documentation in the thread below.

 

http://docs.whmcs.com/Version_6_Template_Migration_Guide#.7Bphp.7D_Block_Syntax

Link to comment
Share on other sites

Hi Brian

 

Thanks for this , I substituted the code from the example and got a bit further but it highlighted other issues with my code - ill have to get a developer to look at it for me and follow up on your suggestions.

 

Thanks for your help!

Kind Regards

Martin

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated