Jump to content

Domain Checker on front page - Load results on another page?


Recommended Posts

Hi All,

 

I am customising the six theme and i am incorporating a copy of the domainchecker on the main page. However, after clicking search i want the results to show in another page rather than underneath but i cannot see how to do this?

 

Here is a snippet of code from my main page:

 

<!--Start of domain name checker-->
<section id="name-checker">
<div>
<div class="searchimg">>
	<img src="images/domain_search.png"></img>
</div>
 <div>
 <div class="domainsearch-txt"><h2> Choose your domain name now, don't miss out </h2>
 </div>
   {include file="$template/domainchecker.tpl"}    
 </div>
</div>
</section>

<!--end of domain name checker-->

 

Here is some of the code from the domainchecker.tpl file which calls the domainchecker-results.tpl:

{include file="$template/includes/alert.tpl" type="danger" msg="{$LANG.searchtermrequired}" textcenter=true idname="searchTermRequired" additionalClasses="domain-checker-error" hide=true}

{include file="$template/includes/alert.tpl" type="danger" msg="{$LANG.invalidchars}" textcenter=true idname="invalidChars" additionalClasses="domain-checker-error" hide=true}

{if $errorMsg}
   {include file="$template/includes/alert.tpl" type="danger" msg=$errorMsg textcenter=true idname="invalidDomainError" additionalClasses="domain-checker-error"}
{else}
   {include file="$template/includes/alert.tpl" type="danger" msg="{$LANG.unabletolookup}" textcenter=true idname="invalidDomainError" additionalClasses="domain-checker-error" hide=true}
{/if}

<div class="domain-checker-container">
   <div class="domain-checker-bg clearfix">
       <form id="frmDomainChecker">
           <div class="row">
               <div class="col-md-8 col-md-offset-2 col-xs-10 col-xs-offset-1">
                   {if $bulkdomainsearchenabled}
                       <div class="domain-bulk-options-box hidden-xs">
                           <a href="domainchecker.php?search=bulk" id="btnBulkOptions" class="btn btn-warning btn-sm" />{$LANG.bulkoptions}</a>
                       </div>
                   {/if}
                   <div class="input-group input-group-lg input-group-box">
                       <input type="text" class="form-control" placeholder="{$LANG.findyourdomain}" value="{$domain}" id="inputDomain" />
                       <span class="input-group-btn">
                           <button type="submit" id="btnCheckAvailability" class="btn btn-primary domain-check-availability">{$LANG.search}</button>
                       </span>
                   </div>
               </div>
           </div>

           {*{include file="$template/includes/captcha.tpl"}*}
       </form>
   </div>
</div>
<div class="domain-step-options hidden" id="stepBulkOptions">
   <textarea class="form-control" rows="10" cols="60" id="inputBulkDomains"></textarea>
</div>
<div class="domain-step-options{if !$performingLookup} hidden{/if}" id="stepResults">
   {include file="$template/domainchecker-results.tpl"}
</div>

 

Here is the domainchecker-results.tpl:

{if $validDomain}

   {if $searchResults}
       <div class="domain-checker-result-headline">
           {if $searchResults.isRegistered}
               <p class="domain-checker-unavailable">
                   {$LANG.domainunavailable1} <strong>{$searchResults.domainName}</strong> {$LANG.domainunavailable2}
               </p>
           {else}
               <p class="domain-checker-available">
                   {$LANG.domainavailable1} <strong>{$searchResults.domainName}</strong> {$LANG.domainavailable2}
               </p>
           {/if}
       </div>
   {/if}

   {if ($searchResults && !$searchResults.isRegistered) || $bulkCheckResults}

       <div class="domainresults" id="primarySearchResults">
           <div id="btnCheckout" class="domain-checkout-area">
               <a href="cart.php?a=view" class="btn btn-default">{$LANG.domainsgotocheckout} »</a>
           </div>
           <div>
               {$LANG.domainssearchresults}
           </div>
           <table class="table table-curved table-hover" id="searchResults">
               <tbody>
                   {if $searchResults}
                       <tr>
                           <td><strong>{$searchResults.domainName}</strong></td>
                           <td class="text-center">
                               <span class="label label-success">{$LANG.domaincheckeravailable}</span>
                           </td>
                           <td class="text-center">
                               {$searchResults.shortestPeriod.register}
                           </td>
                           <td class="text-center">
                               {if count($searchResults.pricing) == 1}
                                   <button type="button" onclick="addToCart(this, false, 'register')" class="btn btn-primary btn-sm">
                                       <span class="glyphicon glyphicon-shopping-cart"></span>
                                       {$LANG.addtocart}
                                   </button>
                               {else}
                                   <div class="btn-group">
                                       <button type="button" class="btn btn-primary btn-sm" onclick="addToCart(this, false, 'register')">
                                           <b class="glyphicon glyphicon-shopping-cart"></b>
                                           {$LANG.addtocart}
                                       </button>
                                       <button type="button" class="btn btn-primary btn-sm dropdown-toggle additional-options" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                           <b class="caret"></b>
                                           <span class="sr-only">
                                               {lang key="domainChecker.additionalPricingOptions" domain=$searchResults.domainName}
                                           </span>
                                       </button>
                                       <ul class="dropdown-menu" role="menu">
                                           {foreach $searchResults.pricing as $years => $price}
                                               {if $price@iteration eq 1}
                                                   {* Don't output the first as this is default *}
                                                   {continue}
                                               {/if}
                                               <li>
                                                   <a onclick="addToCart(this, false, 'register', {$years});return false;">
                                                       {$years} {$LANG.orderyears} @ {$price.register}
                                                   </a>
                                               </li>
                                           {/foreach}
                                       </ul>
                                   </div>
                               {/if}
                           </td>
                       </tr>
                   {/if}
                   {foreach $bulkCheckResults as $result}
                       <tr>
                           <td><strong>{$result.domainName}</strong></td>
                           <td class="text-center">
                               {if $searchingFor == 'register'}
                                   {if $result.isAvailable}
                                       <span class="label label-success">{$LANG.domaincheckeravailable}</span>
                                   {elseif $result.isRegistered}
                                       <span class="label label-danger">{$LANG.domaincheckertaken}</span>
                                   {else}
                                       <span class="label label-danger">Status Unknown</span>
                                   {/if}
                               {else}
                                   {if $result.isRegistered}
                                       <span class="label label-success">{$LANG.domaincheckertransferable}</span>
                                   {elseif $result.isAvailable}
                                       <span class="label label-danger">Not Registered</span>
                                   {else}
                                       <span class="label label-danger">Status Unknown</span>
                                   {/if}
                               {/if}
                           </td>
                           <td class="text-center">
                               {if ($searchingFor == 'register' && $result.isAvailable)}
                                   {$result.shortestPeriod.register}
                               {elseif ($searchingFor == 'transfer' && $result.isRegistered)}
                                   {$result.shortestPeriod.transfer}
                               {/if}
                           </td>
                           <td class="text-right">
                               {if ($searchingFor == 'register' && $result.isAvailable)}
                                   {if count($result.pricing) == 1}
                                       <button type="button" onclick="addToCart(this, false, 'register')" class="btn btn-primary btn-sm">
                                           <span class="glyphicon glyphicon-shopping-cart"></span>
                                           {$LANG.addtocart}
                                       </button>
                                   {else}
                                       <div class="btn-group">
                                           <button type="button" class="btn btn-primary btn-sm" onclick="addToCart(this, false, 'register')">
                                               <b class="glyphicon glyphicon-shopping-cart"></b>
                                               {$LANG.addtocart}
                                           </button>
                                           <button type="button" class="btn btn-primary btn-sm dropdown-toggle additional-options" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                               <b class="caret"></b>
                                           <span class="sr-only">
                                               {lang key="domainChecker.additionalPricingOptions" domain=$result.domainName}
                                           </span>
                                           </button>
                                           <ul class="dropdown-menu" role="menu">
                                               {foreach $result.pricing as $years => $price}
                                                   {if $price@iteration eq 1}
                                                       {* Don't output the first as this is default *}
                                                       {continue}
                                                   {/if}
                                                   <li>
                                                       <a onclick="addToCart(this, false, 'register', {$years});return false;">
                                                           {$years} {$LANG.orderyears} @ {$price.register}
                                                       </a>
                                                   </li>
                                               {/foreach}
                                           </ul>
                                       </div>
                                   {/if}
                               {elseif ($searchingFor == 'transfer' && $result.isRegistered)}
                                   <button type="button" onclick="addToCart(this, false, 'transfer')" class="btn btn-primary btn-sm">
                                       <span class="glyphicon glyphicon-shopping-cart"></span>
                                       {$LANG.addtocart}
                                   </button>
                               {elseif $result.isRegistered}
                                   <a href="http://{$result.domainName}" target="_blank" class="btn btn-default btn-sm">www</a>
                                   <button type="button" onclick="viewWhois('{$result.domainName}')" class="btn btn-default btn-sm">WHOIS</button>
                               {/if}
                           </td>
                       </tr>
                   {/foreach}
               </tbody>
           </table>
       </div>
   {/if}
{/if}
{if $searchResults && count($searchResults.suggestions) > 0}
   <div class="row">
       <div class="col-md-8 col-md-offset-2">
           <div class="domainresults" id="suggestionSearchResults">
               <div>
                   {$LANG.domainssuggestions} <span>{$LANG.domainsothersuggestions}</span>
               </div>
               <table class="table table-curved table-hover" id="suggestionResults">
                   <tbody>
                       {foreach $searchResults.suggestions as $i => $result}
                           <tr{if $i >= 10} class="hidden"{/if}>
                               <td>
                                   <strong>{$result.domainName}</strong>
                               </td>
                               <td class="text-center">
                                   {$result.shortestPeriod.register}
                               </td>
                               <td class="text-right">
                                   {if count($result.pricing) == 1}
                                       <button type="button" onclick="addToCart(this, false, 'register')" class="btn btn-default btn-sm">
                                           <span class="glyphicon glyphicon-shopping-cart"></span>
                                           {$LANG.addtocart}
                                       </button>
                                   {else}
                                       <div class="btn-group">
                                           <button type="button" class="btn btn-default btn-sm" onclick="addToCart(this, false, 'register')">
                                               <b class="glyphicon glyphicon-shopping-cart"></b>
                                               {$LANG.addtocart}
                                           </button>
                                           <button type="button" class="btn btn-default btn-sm dropdown-toggle additional-options" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                               <b class="caret"></b>
                                           <span class="sr-only">
                                               {lang key="domainChecker.additionalPricingOptions" domain=$result.domainName}
                                           </span>
                                           </button>
                                           <ul class="dropdown-menu" role="menu">
                                               {foreach $result.pricing as $years => $price}
                                                   {if $price@iteration eq 1}
                                                       {* Don't output the first as this is default *}
                                                       {continue}
                                                   {/if}
                                                   <li>
                                                       <a onclick="addToCart(this, false, 'register', {$years});return false;">
                                                           {$years} {$LANG.orderyears} @ {$price.register}
                                                       </a>
                                                   </li>
                                               {/foreach}
                                           </ul>
                                       </div>
                                   {/if}
                               </td>
                           </tr>
                       {/foreach}
                       <tr id="trNoMoreSuggestions" class="hidden">
                           <td colspan="3" class="text-muted text-center">
                               {$LANG.domaincheckernomoresuggestions}
                           </td>
                       </tr>
                   </tbody>
               </table>
           </div>
           {if $moreSuggestionsAvailable}
               <p class="text-center">
                   <a href="#" class="btn btn-link" id="btnMoreSuggestions" onclick="showMoreSuggestions();return false">{$LANG.domainsmoresuggestions}</a>
               </p>
           {/if}
           <div class="domain-disclaimer-area">
               <p class="text-muted"><strong>{$LANG.disclaimers}</strong><br />{$LANG.domainssuggestionswarnings}</p>
           </div>
       </div>
   </div>

{/if}

 

i cannot find where i can redirect to show the results on another page?

 

Is it possible just to pass the input to the domainchecker and then open the domainchecker.php page to show the results?

 

Any suggestions would be most welcome.

Regards

Donna

Link to comment
Share on other sites

Donna,

 

Is it possible just to pass the input to the domainchecker and then open the domainchecker.php page to show the results?

perhaps i'm missing the point here, but that's what the homepage does by default without any alteration - it has a cut-down domain search and it passes the search query to domainchecker to begin the search process. :?:

 

http://demo.whmcs.com/

 

effectively, it's just a prettified version of the integration code located within header.tpl...

 

http://docs.whmcs.com/Linking_to_WHMCS#Integrating_a_Domain_Availability_Check_into_your_Website

 

if you wanted to go down this road, i'd be more tempted to remove the include to domainchecker.tpl and tweak the existing code in header.tpl to how you want the search box to look... and let it pass the query to domainchecker to do its function.

Link to comment
Share on other sites

Donna,

 

 

perhaps i'm missing the point here, but that's what the homepage does by default without any alteration - it has a cut-down domain search and it passes the search query to domainchecker to begin the search process. :?:

 

http://demo.whmcs.com/

 

effectively, it's just a prettified version of the integration code located within header.tpl...

 

http://docs.whmcs.com/Linking_to_WHMCS#Integrating_a_Domain_Availability_Check_into_your_Website

 

if you wanted to go down this road, i'd be more tempted to remove the include to domainchecker.tpl and tweak the existing code in header.tpl to how you want the search box to look... and let it pass the query to domainchecker to do its function.

 

Thankyou for your reply. What was/is happening is that the results were expanding in the main page, rather than redirecting to a results page after clicking search. When i modify the code on the homepage and click search it redirects, but does not display the results. it just displays the domainchecker again. Here is my modified code:

 

		<form action="domainchecker.php" method="post" id="frmDomainChecker">
           <div class="row">
               <div class="col-md-8 col-md-offset-2 col-xs-10 col-xs-offset-1">
                   {if $bulkdomainsearchenabled}
                       <div class="domain-bulk-options-box hidden-xs">
                           <a href="domainchecker.php?search=bulk" id="btnBulkOptions" class="btn btn-warning btn-sm" />{$LANG.bulkoptions}</a>
                       </div>
                   {/if}
                   <div class="input-group input-group-lg input-group-box">
                       <input type="text" class="form-control" placeholder="{$LANG.findyourdomain}" value="{$domain}" id="inputDomain" />
                       <span class="input-group-btn">
                           <button type="submit" id="btnCheckAvailability" class="btn btn-primary domain-check-availability">{$LANG.search}</button>
                       </span>
                   </div>
               </div>
           </div>

           {*{include file="$template/includes/captcha.tpl"}*}
       </form>

 

Any suggestions what i am doing wrong here?

 

Best Regards

Donna

Link to comment
Share on other sites

Thankyou for your reply. What was/is happening is that the results were expanding in the main page, rather than redirecting to a results page after clicking search.

that will occur because you're including domainchecker.tpl in your homepage... domainchecker.tpl itself includes an include to domainchecker-results.tpl and so that's why you're seeing the results on the same page...

 

When i modify the code on the homepage and click search it redirects, but does not display the results. it just displays the domainchecker again.

one issue to be aware of when trying to just include templates within other templates is that the included template won't necessarily have access to the variables/arrays that it's trying to use.

 

taking domainchecker.tpl as an example - you can include it in the homepage, but if you do, you will see that it can't display the values within the domain pricing table... this is because the homepage doesn't have access to the domain prices array... yet use the same template in domainchecker.php and you can correctly show the pricing tables... because it does have access to the variables.

 

the point being that including a template is (often) just for show... it doesn't necessarily add the background functions that makes it work in it's default location.

 

if you take a look at the Demo, and enter a domain search string into the box, e.g whmcsdomainchecker.com, enter the captcha and click search, then it will pass it to domainchecker; it will show that the domain is available and also some alternative TLDs too.

 

if your search isn't doing that, then either the initial search code is wrong, or the domainchecker/results templates are wrong - or both.

 

if it helps, the code within header.tpl that is used on the homepage to show the search box is...

 

                <form method="post" action="domainchecker.php">
                   <div class="row">
                       <div class="col-md-8 col-md-offset-2 col-sm-10 col-sm-offset-1">
                           <div class="input-group input-group-lg">
                               <input type="text" class="form-control" name="domain" placeholder="{$LANG.exampledomain}" autocapitalize="none" />
                               <span class="input-group-btn">
                                   {if $registerdomainenabled}
                                       <input type="submit" class="btn btn-warning" value="{$LANG.search}" />
                                   {/if}
                                   {if $transferdomainenabled}
                                       <input type="submit" name="transfer" class="btn btn-info" value="{$LANG.domainstransfer}" />
                                   {/if}
                               </span>
                           </div>
                       </div>
                   </div>

                   {include file="$template/includes/captcha.tpl"}
               </form>

with a clean installation, the process should work correctly... it sounds as though you may have over-modified the templates at either end and the process is now failing.

 

if it were me, i'd change either the header.tpl code or your domainchecker code back to its default, and try again, e.g if the header.tpl code is as above and the process fails, you know the issue lies with domainchecker and/or domainchecker-results... if you're modifying all three at the same time, you're making it harder for yourself to find where the fault is.

Link to comment
Share on other sites

if it were me, i'd change either the header.tpl code or your domainchecker code back to its default, and try again, e.g if the header.tpl code is as above and the process fails, you know the issue lies with domainchecker and/or domainchecker-results... if you're modifying all three at the same time, you're making it harder for yourself to find where the fault is.

 

I managed to fix it with the following:

 

<form action="domainchecker.php" method="post" id="frmDomainChecker">
	<div class="row">
		<div class="col-md-8 col-md-offset-2 col-xs-10 col-xs-offset-1">
           {if $bulkdomainsearchenabled}
               <div class="domain-bulk-options-box hidden-xs">
                   <a href="domainchecker.php?search=bulk" id="btnBulkOptions" class="btn btn-warning btn-sm" />{$LANG.bulkoptions}</a>
               </div>
           {/if}
			<input type="hidden" name="token" value="5cc62271366dec25d55a827d20e96e3a5f82b5a2">
               <input type="hidden" name="direct" value="true">
                   <div class="input-group input-group-lg input-group-box">                       
                       <input name="domain" type="text" class="form-control" placeholder="{$LANG.findyourdomain}">
                       <span class="input-group-btn">
                           <button type="submit" id="btnCheckAvailability" class="btn btn-primary domain-check-availability">{$LANG.search}</button>
                       </span>
                   </div>
		</div>		
       </form>

 

I found another site which uses WHMCS and behaved how i wanted mine too, then copied the source code and modified it to my site. Im not really sure what the issue was but i get the behaviour i was looking for. Thankyou for your support :) I'm sure i will be back again in the near future.

Have a great day

Donna :)

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