Search the Community
Showing results for tags 'instant search'.
-
To activate the intelligent search to query results while typing instead of pressing the "Enter" key each time I have created simple ActionHook function that will integrate the code for both built-in template (v4 and Blend), the integration tested and is valid for WHMCS v6+ and v7+ 1) Create new PHP file inside /includes/hooks/ directory, you may use "IntelliSearchWhileTyping.php" as the file name or whatever you prefer. 2) Copy the following code inside it. 3) Done. <?php /** * Get Results From Intelligent Search While Typing * * Compatible with WHMCS v6+ and v7+ * Works with v4 and Blend templates * * @author SENTQ <development@sentq.com> * */ if (!defined("WHMCS")){ die("This file cannot be accessed directly"); } add_hook("AdminAreaHeadOutput", 1, function($vars){ # Template Blend if ($vars['template'] === "blend"){ return <<<EOF <script type="text/javascript"> /* Intelligent Search On Typing */ $(document).ready(function(){ $(document).on("input", "#intellisearchval", function(){ $("#intellisearchval").css("background-image","url('images/loading.gif')"); $.post("search.php", $("#frmintellisearch").serialize(), function(data){ $("#searchresultsscroller").html(data); $("#searchresults").slideDown("slow",function(){ $("#intellisearchval").css("background-image","url('images/icons/search.png')"); }); }); }); }); </script> EOF; } # Template v4 elseif ($vars['template'] === "v4"){ return <<<EOF <script type="text/javascript"> /* Intelligent Search On Typing */ $(document).ready(function(){ $(document).on("input", "#intellisearchval", function() { $.post("search.php", $("#frmintellisearch").serialize(), function(data){ if (data) { $("#searchresults").html(data); $("#btnIntelliSearch").hide(); $("#btnIntelliSearchCancel").removeClass('hidden').show(); $("#searchresults").hide().removeClass('hidden').slideDown(); } }); }); }); </script> EOF; } }); IntelliSearchWhileTyping.php
- 14 replies
-
- intelligent search
- search
-
(and 2 more)
Tagged with:
-
May you please advise? I've got tons of notes and tabs, and I feel like I'm really close. If you would like to lend some of your time and wisdom, I would be most grateful. I'm looking to contribute my first community addon to WHMCS. I wish to query the tblknowledgebase table and return title and id into typeahead array that'll then open the echo in new tab / window. Did I say that right? https://i.imgur.com/zu27hyb.png This is where I'm at now: <?php $key=$_GET['key']; $array = array(); $con=mysql_connect("localhost","dbuser","dbpass"); $db=mysql_select_db("dbname",$con); $query=mysql_query("select * from tblknowledgebase where title LIKE '%{$key}%'"); // I just duped above line and replaced title with ID $query=mysql_query("select * from tblknowledgebase where id LIKE '%{$key}%'"); while($row=mysql_fetch_assoc($query)) { $array[] = [u]$row['title'][/u]; // missing the row ID stuff and concenate stuff } echo json_encode($array); ?> https://i.imgur.com/ZKC7D4t.png This is what I desire output of $array[]: <a href="knowledgebase.php?action=displayarticle&id={$kbarticle.id}" target="_blank">$row['title']</a> <a href="knowledgebase.php?action=displayarticle&id=$row['title']" target="_blank">$row['title']</a> Href stuff pulled from file: supportticketsubmit-kbsuggestions.tpl Starting tutorial: https://codeforgeek.com/2014/09/ajax-search-box-php-mysql/ keywords used during research • typeahead mysql fetch "link" + "href" • add href OR link to $array[] = $row[ • json_encode href • php concenate $row[' misc • concenate • mysql = deprecated? • mysqli = new? • http://www.codingcage.com/2016/12/autocomplete-search-with-href-link-php.html • http://www.discussdesk.com/autocomplete-search-in-php-mysql-json-with-navigation.htm • http://bit.ly/2nGCVGf • http://au1.php.net/json_encode • https://datatables.net/forums/discussion/28891/adding-hyperlink-to-each-row • https://github.com/bassjobsen/Bootstrap-3-Typeahead
- 1 reply
-
- ajax search
- instant search
-
(and 2 more)
Tagged with:
