stormy Posted November 28, 2018 Share Posted November 28, 2018 (edited) 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 November 28, 2018 by stormy 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 28, 2018 Share Posted November 28, 2018 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"); 2 Quote Link to comment Share on other sites More sharing options...
stormy Posted November 28, 2018 Author Share Posted November 28, 2018 (edited) Awesome! Is there any advantage of the hook over editing the template? Besides not needing to edit the template, of course 🙂 Edited November 28, 2018 by stormy 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 28, 2018 Share Posted November 28, 2018 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. 1 Quote Link to comment Share on other sites More sharing options...
edvancombr Posted November 28, 2018 Share Posted November 28, 2018 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. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 28, 2018 Share Posted November 28, 2018 5 minutes ago, edvancombr said: Can not this customization work for the correct homepage? http://prntscr.com/lo6a2d does it need to? click the search button, and the current hook modifies the search term... unless you're telling me otherwise, I don't see the need to expand it for the homepage. 0 Quote Link to comment Share on other sites More sharing options...
stormy Posted November 28, 2018 Author Share Posted November 28, 2018 2 minutes ago, brian! said: click the search button, and the current hook modifies the search term... There's another reason for using the hook instead of modifying the template! 0 Quote Link to comment Share on other sites More sharing options...
edvancombr Posted November 28, 2018 Share Posted November 28, 2018 4 minutes ago, brian! said: does it need to? click the search button, and the current hook modifies the search term... unless you're telling me otherwise, I don't see the need to expand it for the homepage. You are right! I had removed the hook. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 28, 2018 Share Posted November 28, 2018 2 minutes ago, stormy said: There's another reason for using the hook instead of modifying the template! i'd imagine it would do the same with your original template edit too - though I didn't try it. 0 Quote Link to comment Share on other sites More sharing options...
stormy Posted November 28, 2018 Author Share Posted November 28, 2018 1 minute ago, brian! said: i'd imagine it would do the same with your original template edit too - though I didn't try it. Not if you use external forms that post to the domain search. So this is the better option overall!!! 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 28, 2018 Share Posted November 28, 2018 3 minutes ago, stormy said: Not if you use external forms that post to the domain search. it would work if you put your template code in footer.tpl rather than domainregister.tpl - as that's basically all this hook is doing anyway. 0 Quote Link to comment Share on other sites More sharing options...
stormy Posted November 28, 2018 Author Share Posted November 28, 2018 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. 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.