Support forums > Themes
[RESOLVED] Exclude category from results search ajax autocomplete
leuname07:
Hello,
I need to exclude my adult category in ajax autocomplete results. Anyone can help me ? This the code and my theme is Veronika.
--- Code: ---<div class="header-search-mobile is767">
<form action="<?php echo osc_base_url(true); ?>" method="get" class="search nocsrf" >
<input type="hidden" name="page" value="search" />
<div class="input-box">
<button type="submit"><i class="fa fa-search"></i></button>
<input type="text" name="sPattern" id="query" value="<?php echo osc_esc_html(osc_search_pattern()); ?>" placeholder="<?php _e('Search...', 'veronika'); ?>" autocomplete="off" />
</div>
<i class="fa fa-ellipsis-v open-h-search"></i>
</form>
</div>
<?php if(osc_get_preference('search_box_home', 'veronika_theme') == '1') { ?>
<div id="header-search">
<div class="inside">
<div class="wrap round3">
<form action="<?php echo osc_base_url(true); ?>" method="get" class="search nocsrf" >
<input type="hidden" name="page" value="search" />
<input type="hidden" name="cookieAction" id="cookieAction" value="" />
<input type="hidden" name="sCountry" id="sCountry" value="<?php echo Params::getParam('sCountry'); ?>"/>
<input type="hidden" name="sRegion" id="sRegion" value="<?php echo Params::getParam('sRegion'); ?>"/>
<input type="hidden" name="sCity" id="sCity" value="<?php echo Params::getParam('sCity'); ?>"/>
<div class="top">
<div class="large">
<div class="b1">
<div class="label"><h1><?php _e('Petites annonces gratuites - Que cherchez-vous ?', 'veronika'); ?></h1></div>
<div class="box">
<?php if (osc_get_preference('item_ajax', 'veronika_theme') == 1) { ?>
<div id="item-picker">
<input type="text" name="sPattern" class="pattern" placeholder="<?php _e('Samsung S7 Edge...', 'veronika'); ?>" value="<?php echo Params::getParam('sPattern'); ?>" autocomplete="off"/>
<div class="shower-wrap">
<div class="shower" id="shower">
<div class="option service min-char"><?php _e('Type keyword', 'veronika'); ?></div>
</div>
</div>
<div class="loader"></div>
</div>
<?php } else { ?>
<input type="text" name="sPattern" placeholder="<?php _e('Samsung S7 Edge...', 'veronika'); ?>" value="<?php echo Params::getParam('sPattern'); ?>" autocomplete="off"/>
<?php } ?>
</div>
</div>
<div class="b3">
<div class="label"> </div>
<div class="box"><button type="submit" class="round3 tr1"><?php _e('Search', 'veronika'); ?></button></div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
<?php } ?>
--- End code ---
leuname07:
Help... please !
WEBmods:
Hello!
This is a premium theme, which means I don't have access to it. You did provide some code but it's not enough. I believe we need autocomplete JS and AJAX function for autocomplete to (try to) do something...
Regards.
leuname07:
This is the code in footer :
--- Code: --- <?php if(osc_get_preference('item_ajax', 'veronika_theme') == 1) { ?>
// JAVASCRIPT AJAX LOADER FOR ITEMS AUTOCOMPLETE
var patternClicked = false;
// On first click initiate loading
$('body').on('click', '#item-picker .pattern', function() {
if( !patternClicked ) {
$(this).keyup();
}
patternClicked = true;
});
// Create delay
var delay2 = (function(){
var timer2 = 0;
return function(callback, ms){
clearTimeout (timer2);
timer2 = setTimeout(callback, ms);
};
})();
//$(document).ajaxStart(function() {
//$("#item-picker, .item-picker").addClass('searching');
//});
$(document).ajaxSend(function(evt, request, settings) {
var url = settings.url;
if (url.indexOf("ajaxItem") >= 0) {
$("#item-picker, .item-picker").addClass('searching');
}
});
$(document).ajaxStop(function() {
$("#item-picker, .item-picker").removeClass('searching');
});
$('body').on('keyup', '#item-picker .pattern', function(e) {
delay(function(){
var min_length = 3;
var elem = $(e.target);
var pattern = elem.val();
var block = elem.closest("#item-picker");
var shower = elem.closest("#item-picker").find(".shower");
shower.html('');
if(pattern != '' && pattern.length >= min_length) {
// Combined ajax for country, region & city
$.ajax({
type: "POST",
url: baseAjaxUrl + "&ajaxItem=1&pattern=" + pattern,
dataType: 'json',
success: function(data) {
var length = data.length;
var result = '';
if(shower.find('.service.min-char').length <= 0) {
for(key in data) {
// When item already is not in shower
if(shower.find('div[data-item-id="' + data[key].pk_i_id + '"]').length <= 0) {
result += '<a class="option" data-item-id="' + data[key].pk_i_id + '" href="' + data[key].item_url + '" title="<?php echo osc_esc_js(__('Click to open listing', 'veronika')); ?>">'
result += '<div class="left"><img src="' + data[key].image_url + '"/></div>';
result += '<div class="right">';
result += '<div class="top">' + data[key].s_title + '</div>';
result += '<div class="bottom">' + data[key].i_price + '</div>';
result += '</div>';
result += '</a>';
}
}
// No city, region or country found
if( length <= 0) {
shower.find('.option').remove();
result = '<div class="option service empty-pick"><?php echo osc_esc_js(__('No listing match to your criteria', 'veronika')); ?></div>';
}
}
shower.html(result);
}
});
} else {
// Term is not length enough
shower.html('<div class="option service min-char"><?php echo osc_esc_js(__('Enter at least', 'veronika')); ?> ' + (min_length - pattern.length) + ' <?php echo osc_esc_js(__('more letter(s)', 'veronika')); ?></div>');
}
}, 500 );
});
<?php } ?>
--- End code ---
leuname07:
Any help please ?
Navigation
[0] Message Index
[#] Next page
Go to full version