Сообщение от
lesnik
не презентабельно смотрится отсутствие фото у более 50 % товаров)
Все зависит от ассортимента, у моих конкурентов вообще фото нет, но это им не мешает делать миллионные обороты. А вот модуль подправленный.
vi_search_autocomplite.php
PHP код:
<?php
if (isset($_GET['term']) &&!empty($_GET['term'])) {
include_once('../includes/date_functions.php');
include_once('../includes/var_definition.php');
include_once('../includes/common_functions.php');
include_once('../includes/va_functions.php');
include_once('../includes/db_'.$db_type.'.php');
include_once('../includes/products_functions.php');
$db = new VA_SQL();
$db->DBType = $db_type;
$db->DBDatabase = $db_name;
$db->DBHost = $db_host;
$db->DBPort = $db_port;
$db->DBUser = $db_user;
$db->DBPassword = $db_password;
$db->DBPersistent= $db_persistent;
$settings = va_settings();
$product_no_image = get_setting_value($settings, "product_no_image", "");
$query=trim(strip_tags($_GET['term']));
$m_s = explode(" ",$db->tosql($query,TEXT,false));
$str ='';
foreach ($m_s as $value) {
if ($value !='')
if ($str !='') $str = $str." AND i.item_name LIKE '%".$value."%'";
else $str = " i.item_name LIKE'%".$value."%'";
}
$sql = 'SELECT i.item_name, i.tiny_image, i.item_id FROM '.$table_prefix ."items AS i WHERE ".$str ."";
$db->query($sql);
if ($db->next_record()){
do {
$row['value']=htmlspecialchars($db->f('item_name'));
$row['id']=(int)$db->f('item_id');
$small_image=$db->f('tiny_image');
if (!strlen($small_image))
$small_image = $product_no_image;
$row['tiny_image']=$small_image;
$row_set[] = $row;
}while ($db->next_record());
echo json_encode($row_set);
}
return false;
}
if (isset($vars['tag_name'])) {
$html_template = get_setting_value($block,'html_template','vi_search_autocomplite.html');
$t->set_file('block_body',$html_template);
}
//$t->set_var('search_href',get_custom_friendly_url('site_search.php'));
$t->set_var('search_href',get_custom_friendly_url('products_search.php'));
$q = trim(get_param('q'));
$sq = trim(get_param('sq'));
$t->set_var('q',htmlspecialchars($q));
$t->set_var('sq',htmlspecialchars($sq));
if (isset($vars['tag_name'])) {
$block_parsed = true;
};
?>
vi_search_autocomplite.html
Код HTML:
<div class="block-site-search-form searchIco {block_class}" style="">
<script src="./js/extra/jquery-ui-1.9.1.custom.min.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
$(function() {
function log( message ) {
$( "<div>" ).text( message ).prependTo( "#log" );
$( "#log" ).scrollTop( 0 );
}
function LoadCSS() {
var $ = document; // shortcut
var cssId = 'vi_search_autocomplete';
if (!$.getElementById(cssId)){
var head = $.getElementsByTagName('head')[0];
var link = $.createElement('link');
link.id = cssId;
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = './styles/extra/ui-blue/jquery-ui-1.9.1.custom.css';
link.media = 'all';
head.appendChild(link);}
}
LoadCSS();
$( "#vi_autocomplete" ).autocomplete({
source: "./blocks/vi_search_autocomplite.php",
minLength: 2,
select: function( event, ui ) {
location.href = 'product_details.php?item_id=' + ui.item.id;
}
})
.data( "autocomplete" )._renderItem = function( ul, item ) {
return $( "<li>" )
.data( "item.autocomplete", item )
.append( "<a style='line-height:1em;'>" +"<img src='"+item.tiny_image+"' style='width:40px;height:40px;text-align:left;vertical-align:middle; margin:3px;'>"+ item.value +"</a>" )
.appendTo( ul );
};
});
//]]>
</script>
<form action="{search_href}" method="get">
<input class="searchField" type="text" name="search_string" value="{q}" id="vi_autocomplete"/>
<input
class="searchSubmit" type="submit" name="search"
value="{SEARCH_BUTTON}" />
</form>
</div>
Социальные закладки