Jump to content

Domain extension in domain suggestion cart


sebsimappus

Recommended Posts

Domain extension in domain suggestion cart

 

Hello,

 

I come to you because I have been trying for several hours to find out how to use only the extension of the domain.

 

I would like to replace the domain extension with an image.

 


{if $othersuggestions}
	<div class="suggested-domains" style="">
		<div class="panel-heading">
           	{$LANG.cartotherdomainsuggestions}
           </div>
           <div class="spotlight-tlds clearfix">
			<div class="spotlight-tlds-container">
				{foreach from=$othersuggestions item=other}
					<div class="spotlight-tld-container spotlight-tld-container-3">
						<div class="spotlight-tld-news">
							{$tld}
						</div>
							<!--<input type="checkbox" class="css-checkbox-check" name="domains[]" value="{$other.domain}" id="checkboxdomain {$other.domain}" onchange="{if $smarty.request.adddomaincustom eq '1'}adddomain(this.value,$(this).is(':checked'));{else}completedomain(this.value,$(this).is(':checked'));{/if}" />
							<label class="css-label-check radGroup1" for="checkboxdomain {$other.domain}"></label>-->

							<div class="prepend-icon">
								<label class="field-icon">
									<i class="glyphicon glyphicon-shopping-cart"></i>
								</label>
								<select id="new-select-domain" class="field" onchange="{if $smarty.request.adddomaincustom eq '1'}  adddomain(); {else} completedomain();{/if}" name="domainsregperiod[{$other.domain}]">
									{foreach from=$other.regoptions key=period item=regoption}
										{if $regoption.register}
											<option value="{$period}">{$period} {$LANG.orderyears} @ {$regoption.register}</option>
										{/if}
									{/foreach}
								</select>
							</div>
					</div>
				{/foreach}
			</div>
		</div>
	{assign var='continueok' value=true}

{/if}

 

Big thanks

Link to comment
Share on other sites

you mean that you want to use an image for ".com"; another image for ".net" etc ? something along the lines of...??

 

Screenshot_28b.png

 

with v7, these domain suggestion searches uses ajax/jquery far more than previous versions - so there's little that you can do in the Smarty templates by tweaking the above code.

 

what you'll need to do is edit the jquery code - specifically /templates/orderforms/standard_cart/js/scripts.min.js and change...

 

.find("span.extension").html("."+a).end()

to...

 

.find("span.extension").html("<img src='"+a+".png'>").end()

then you'll need to upload your images/logos for every TLD (I hope you don't have hundreds!) to your WHMCS installation - for simplicity, I haven't bothered with paths and i've just uploaded the images to the WHMCS root - but you could upload them anywhere and change the above code to use the correct path. :idea:

 

there are two other things to bear in mind...

 

1. be aware that WHMCS might (likely will) update the scripts.min.js file during future WHMCS updates - so remember to check and add the above code back in if that occurs.

2. it's possible that a future WHMCS update to the file may prevent this solution from working - so again, check after each update that it still works.

Link to comment
Share on other sites

  • 1 month later...
I use ajaxcart

oh ok - ajaxcart was removed in v6 in 2015 and so hasn't been updated for 2 years... which version of WHMCS are you using it with ??

 

looking at my old v5 dev, in domainoptions.tpl you should be able to split $other.domain into sld and tld using Smarty; then replace tld with an image... how to do it exactly would depend on your WHMCS version - if it's 6 or 7, then it should be easy - if it's v5, it might be a little harder.

Link to comment
Share on other sites

I use the latest version of WHMCS, I have updated ajaxcart for WHMCS 7.1.1

aaah - now the code in the first post makes more sense! :roll:

 

it would probably be helpful to have an image/url link (by PM if necessary) of what it looks like, as from the above code, I can't quite tell where it's displaying the domain name... I assume it should be inside the label?

 

                                <input type="checkbox" class="css-checkbox-check" name="domains[]" value="{$other.domain}" id="checkboxdomain {$other.domain}" onchange="{if $smarty.request.adddomaincustom eq '1'}adddomain(this.value,$(this).is(':checked'));{else}completedomain(this.value,$(this).is(':checked'));{/if}" /> 
                               <label class="css-label-check radGroup1" for="checkboxdomain {$other.domain}">{$other.domain}</label>

if so, then the solution will be as suggested earlier to split $other.domain into SLD and TLD, then replace TLD with an image.

 

{assign domsearch $other.domain|strpos:"."} 
{assign sld $other.domain|substr:0:$domsearch} 
{assign tld $other.domain|substr:($domsearch+1)}
{assign tldlogo "{$tld|strtolower}.png"}
<input type="checkbox" class="css-checkbox-check" name="domains[]" value="{$other.domain}" id="checkboxdomain {$other.domain}" onchange="{if $smarty.request.adddomaincustom eq '1'}adddomain(this.value,$(this).is(':checked'));{else}completedomain(this.value,$(this).is(':checked'));{/if}" /> 
<label class="css-label-check radGroup1" for="checkboxdomain {$other.domain}">{if file_exists($tldlogo)}{$sld}<img src="{$tldlogo}">{else}{$other.domain}{/if}</label>

 

now I can't test it using your template, but I think it should work... I quickly tweaked the modern/domainoptions.tpl template (which also uses $other.domain) to do this and it works fine.

 

agWbPMZ.png

 

it works by first splitting $other.domain into 2 parts: SLD (whmcs2017); TLD (com); it then checks to see if there's an logo image available for TLD... if there is, it outputs SLD+logo; if there isn't, it just outputs $other.domain - that way, the results will always be shown correctly and gives you the option of only using logos for those TLDs you want to highlight. :idea:

 

for simplicity, the logo images are currently assumed to be in the root of the whmcs installation - if you want to move them to assets etc, that's not a problem - just adjust the path in the $tldlogo variable.

 

Does anyone know where to find a good pack of the domain tld images ?

I certainly don't! :roll:

 

when I wrote my original answer, I used the logos from the marketing kits I got from one of our registrars and resized each one online - until you try to resize them to roughly the same dimensions, it's surprising how varied their sizes are... let's just say, it was a pain to do and that's why I only did 5. :cry:

Link to comment
Share on other sites

I certainly don't! :roll:

 

when I wrote my original answer, I used the logos from the marketing kits I got from one of our registrars and resized each one online - until you try to resize them to roughly the same dimensions, it's surprising how varied their sizes are... let's just say, it was a pain to do and that's why I only did 5. :cry:

 

I have been grabbing them from the marketing kits also from my registrar, and its a pain in the arse. I havnt got to the resizing yet, and I have 513 domain extensions I am going to try and get to them all.

Link to comment
Share on other sites

Is a big thank you for your help, I add your code, but unfortunately it does not work, to make simple it does not mark anything, it's just white.

The smarty php tag function is enabled in the admin section.

you shouldn't need to do that for this - it's not PHP, just Smarty - so you don't need to wrap it in {php} tags - just copy & paste into the template.

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