The trick is when submit the article, the category value is id not text, so we need a hidden input to store the id retrieve from database hesk_kb_categories, then submit this id.

1. admin new article - category - auto complete - create search php
D:\wamp\www\hesk\admin\pseries_id_check.php
Code: Select all
<?php
define('IN_SCRIPT',1);
define('HESK_PATH','../');
/* Get all the required files and functions */
require(HESK_PATH . 'hesk_settings.inc.php');
require(HESK_PATH . 'inc/common.inc.php');
require(HESK_PATH . 'inc/database.inc.php');
hesk_dbConnect();
$q = strtolower($_GET["q"]);
if (!$q) return;
$sql = "select id,name from hesk_kb_categories where name LIKE '%$q%'";
$rsd = mysql_query($sql);
while($rs = mysql_fetch_array($rsd)) {
$pid = $rs['id'];
$pserie = $rs['name'];
echo "$pserie|$pid\n";
}
?>
D:\wamp\www\hesk\admin\manage_knowledgebase.php
line 92
Code: Select all
"<html>
<head>
<meta charset=""UTF-8"" />
<script type=""text/javascript"" src=""../js/jquery-1.4.2.js""></script>
<script type='text/javascript' src='../js/lib/jquery.bgiframe.min.js'></script>
<script type='text/javascript' src='../js/lib/jquery.ajaxQueue.js'></script>
<script type='text/javascript' src=""../js/jquery.autocomplete.js""></script>
<link rel=""stylesheet"" type=""text/css"" href=""../js/jquery.autocomplete.css"" />
<script type=""text/javascript"">
$().ready(function() {
$(""#pcategory"").autocomplete(""pseries_id_check.php"", {
width: 320,
matchContains: true,
mustMatch: true,
minChars: 2,
selectFirst: false
});
$(""#pcategory"").result(function(event, data, formatted) {
$(""#serie_id"").val(data[1]);
});
});
</script>
</head>
</html>"
D:\wamp\www\hesk\admin\manage_knowledgebase.php
line 315
from
to<td><select name="catid"><?php $listBox->printMenu(); ?></select></td>
Code: Select all
<!--<td><select name="catid"><?php $listBox->printMenu(); ?></select></td>-->
<td><input type="text" name="pcategory" id="pcategory" size="46" /><button type="reset" value="reset">Clear</button><input type="text" name="serie_id" id="serie_id" size="10" /></td>
D:\wamp\www\hesk\admin\manage_knowledgebase.php
line 1883
from
to$catid = hesk_isNumber($_POST['catid']) or $catid = 1;
Code: Select all
$catid = hesk_isNumber($_POST['serie_id']) or $catid = 1;