Jump to content

Filter out from domain search: www, slashes, http, etc.


Recommended Posts

Put this code in the bottom of domainregister.tpl to get rid of any extraneous stuff that customers will type into a domain search: "www.", slashes, https, spaces, etc.

By the way, this also solves a bug I've reported, where searching for a domain with "www.", like "www.thedomainiwant.com" will return "www.com is unavailable".

<script>
  jQuery('#frmDomainChecker').submit(function() {
      var domain = jQuery('input[name="domain"]').val();
      domain = domain.replace("www.", "");
      domain = domain.replace("http://", "");
      domain = domain.replace("https://", "");
      domain = domain.replace(" ", "");
      domain = domain.replace("/", "");
      domain = domain.toLowerCase();
      jQuery('input[name="domain"]').val(domain);
      return true;
  });
</script>

 

Edited by stormy
Link to comment
Share on other sites

1 hour ago, stormy said:

Put this code in the bottom of domainregister.tpl to get rid of any extraneous stuff that customers will type into a domain search: "www.", slashes, https, spaces, etc.

which as a hook would be...

<?php

# Domain Search Filter Hook
# Originally written by stormy
# Hooked by brian!

function domain_search_filter_hook($vars) {
	
	if ($vars['templatefile'] == "domainregister") {
	
	return <<<EOF
	<script>
  jQuery('#frmDomainChecker').submit(function() {
      var domain = jQuery('input[name="domain"]').val();
      domain = domain.replace("www.", "");
      domain = domain.replace("http://", "");
      domain = domain.replace("https://", "");
      domain = domain.replace(" ", "");
      domain = domain.replace("/", "");
      domain = domain.toLowerCase();
      jQuery('input[name="domain"]').val(domain);
      return true;
  });
</script>
EOF;
	}
};
add_hook("ClientAreaFooterOutput",1,"domain_search_filter_hook");
Link to comment
Share on other sites

3 hours ago, stormy said:

Awesome! Is there any advantage of the hook over editing the template? Besides not needing to edit the template, of course 🙂

not needing to edit the template would be the main selling point of using the hook... of course, if you've already made changes to the template, then it's not strictly necessary, but if this is the only (non-CSS) change a user wants to make to their domain registration page, then it would make sense to use a hook.

Link to comment
Share on other sites

10 minutes ago, brian! said:

not needing to edit the template would be the main selling point of using the hook... of course, if you've already made changes to the template, then it's not strictly necessary, but if this is the only (non-CSS) change a user wants to make to their domain registration page, then it would make sense to use a hook.

Can not this customization work for the correct homepage? http://prntscr.com/lo6a2d

I even removed the conditional from the template.

 

Link to comment
Share on other sites

Ah, I didn't look at the "ClientAreaFooterOutput" part.

By the way, I've added to this hook another useful snippet to filter question marks from knowledgebase searches:

jQuery('#kbsearch').submit(function() {
    var search = jQuery('#kbsearch input[name="search"]').val();
    search = search.replace(/\?/g, "");
    search = search.replace(/\¿/g, "");
    jQuery('#kbsearch input[name="search"]').val(search);
    return true;
});

Customers will frequently use question marks and they get less search results because they are used in the actual search.

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