Hello
I have a need to run 2 instances of AjaxSearch: 1 snippet call per one Tab (See attached preview).
The problem is that there are a several troubles:
1. it alerts "AjaxSearch version obsolete. Empty your browser cache and check the version of AjaxSearch-jQuery.js file" on page load. I have read the forum post about fixing it with cleaning up the cache,etc, inc comparing and making sure that JS is of the same version as php.. but it does not help .. so I just skipped this problem and click OK to let the page load.
2. when page ready and tabs shown, user can click to tab HOUSE or CONDO. HOUSE tab have a hidden input field for TV property = house, and tab CONDO has nearly the same snippet call but hidden input field for TV property = condo. There are more select boxes like price, or number of rooms but at least it needs to search per selected tab and input string input type = text name = search. The thing is that despite the above js alert the AJAX request works per both tabs but it does not run in advanced mode. I mean it does not react to the value of hidden input called property. I have noted that it actually loads the custom config but seems does not use the function inside of it.
Here are more details:
2 snippets calls:
[!AjaxSearch?
&ajaxSearch=`2`
&asId=`asc`
&addJscript=`0`
&jscript=`jquery`
&parents=`1,40,1068`
&tplInput=`realEstate1InputCnd`
&config=`realEstate`
&withTvs=`+:property,bedrooms1,location,condorentprice,condosaleprice`
&tvPhx=`property,bedrooms1,location,condorentprice,condosaleprice`
&tplResult=`realEstate1Result1`
&debug=`3`
&whereSearch=`content|tv`
&minChars=`0` &showPagingAlways=`1`
!]
&config=`realEstate` is
<?php
/* -----------------------------------------------------------------------------
* Input 4, 5 & 6 Form configuration
* ------------------------------------------------------------------------------
* @author Coroico <[email protected]>
* Purpose:
*/
if(!function_exists('asfConfig')) {
function asfConfig($form, & $get){
global $modx;
$where_array = array();
$where = '';
global $modx;
switch ($form) {
case "restate":
unset($ctg, $tag, $loc);
//tv property
if ((isset($_POST['property']) && $_POST['property']!='') || (isset($_GET['property']) && $_GET['property']!='')){
$ctg = isset($_POST['property']) ? strip_tags($_POST['property']) : strip_tags($_GET['property']);
$get['property'] = $ctg;
$where_array[] = 'FIND_IN_SET(\'' . $ctg .'\',property)';
}
//tv bedrooms1
if ((isset($_POST['bedrooms1']) && ($_POST['bedrooms1'])!='') || (isset($_GET['bedrooms1']) && ($_GET['bedrooms1']!=''))){
$tag = isset($_POST['bedrooms1']) ? strip_tags($_POST['bedrooms1']) : strip_tags($_GET['bedrooms1']);
$get['bedrooms1'] = $tag;
$where_array[] = 'FIND_IN_SET(\'' . $tag .'\',bedrooms1)';
}
// Location
if ((isset($_POST['location']) && ($_POST['location']!='')) || (isset($_GET['location']) && ($_POST['location']!=''))){
$loc = isset($_POST['location']) ? strip_tags($_POST['location']) : strip_tags($_GET['location']);
$get['location'] = $loc;
$where_array[] = 'FIND_IN_SET(\'' . $loc .'\',location)';
}
// condorentprice
if ((isset($_POST['condorentprice']) && ($_POST['condorentprice']!='')) || (isset($_GET['condorentprice']) && ($_POST['condorentprice']!=''))){
$pr1 = isset($_POST['condorentprice']) ? strip_tags($_POST['condorentprice']) : strip_tags($_GET['condorentprice']);
$get['condorentprice'] = $pr1;
$where_array[] = 'FIND_IN_SET(\'' . $pr1 .'\',condorentprice)';
}
//condosaleprice
if ((isset($_POST['condosaleprice']) && ($_POST['condosaleprice']!='')) || (isset($_GET['condosaleprice']) && ($_POST['condosaleprice']!=''))){
$pr2 = isset($_POST['condosaleprice']) ? strip_tags($_POST['condosaleprice']) : strip_tags($_GET['condosaleprice']);
$get['condosaleprice'] = $pr2;
$where_array[] = 'FIND_IN_SET(\'' . $pr2 .'\',condosaleprice)';
}
$where = implode(' AND ',$where_array);
break;
}
return $where;
}
}
?>
in non-ajax mode the sql "FIND_IN_SET" is there and it works but in ajax-mode enabled it looks like there is no sql "FIND_IN_SET" in SQL criteria. Please see log:
http://pastebin.com/HJHJk7YU
The input realEstate1InputCnd tpl is
[+as.showInputForm:is=`1`:then=`
<div class="restateInput">
<form action="[+as.formAction+]" method="post" id="[+as.formId+]" >
<fieldset class="inputAS2">
[+as.showAsId:is=`1`:then=`<input type="hidden" name="[+as.asName+]" value="[+as.asId+]" />`+]
<input type="hidden" name="asf" value="restate" />
<div>
<input type="hidden" name="property" value="Condo" />
</div>
<div>
<label>Number of Bedrooms:</label> [[AsSelectTv? &name=`bedrooms1` &tvName=`bedrooms1` &filter=`bedrooms1` &tplName=`New Condo for Sale` &first=``]]
</div><br />
<div>
<label>Location:</label> [[AsSelectTv? &name=`location` &tvName=`location` &filter=`location` &tplName=`New Condo for Sale` &first=``]]
</div><br />
<div>
<label>Size:</label> <!-- [[AsSelectTv? &name=`location` &tvName=`location` &filter=`location` &tplName=`New Condo for Sale` &first=``]] -->
</div><br />
<div>
<label>Price:</label> rent [[AsSelectTv? &name=`condorentprice` &tvName=`condorentprice` &filter=`condorentprice` &tplName=`New Condo for Rent` &first=``]]
sale [[AsSelectTv? &name=`condosaleprice` &tvName=`condosaleprice` &filter=`condosaleprice` &tplName=`New Condo for Sale` &first=``]]
</div><br />
<div>
<label>ref Number:</label><input id="[+as.inputId+]" class="cleardefault" type="text" name="search" value="" />
</div><br />
<br /><br />
<input id="[+as.submitId+]" type="submit" name="sub" value="Property Search" />
</fieldset>
</form>
</div>
<br />
`+]
The second tab for HOUSE has snippet call:
[!AjaxSearch?
&ajaxSearch=`2`
&asId=`ash`
&jscript=`jquery`
&addJscript=`0`
&parents=`1,40,1068`
&tplInput=`realEstate1InputHouse`
&config=`realEstate`
&withTvs=`+:property,bedrooms1,location,houserentprice,housesaleprice`
&tvPhx=`property,bedrooms1,location,houserentprice,housesaleprice`
&tplResult=`realEstate1Result1`
&debug=`3`
&whereSearch=`content|tv`
&minChars=`0` &showPagingAlways=`1`
!]
and it's input tpl is
[+as.showInputForm:is=`1`:then=`
<div class="restateInput">
<form action="[+as.formAction+]" method="post" id="[+as.formId+]" >
<fieldset class="restate">
<input type="hidden" name="asf" value="restate" />
<div>
<input type="hidden" name="property" value="House" />
</div><br />
<div>
<label>Number of Bedrooms:</label> [[AsSelectTv? &name=`bedrooms1` &tvName=`bedrooms1` &filter=`bedrooms1` &tplName=`New House for Sale` &first=``]]
</div><br />
<div>
<label>Location:</label> [[AsSelectTv? &name=`location` &tvName=`location` &filter=`location` &tplName=`New House for Sale` &first=``]]
</div><br />
<!--div>
<label>Size:</label--> <!-- [[AsSelectTv? &name=`location` &tvName=`location` &filter=`size` &tplName=`New House for Sale` &first=``]] -->
<!--/div><br /-->
<div>
<label>Price:</label>rent [[AsSelectTv? &name=`condorentprice` &tvName=`houserentprice` &filter=`houserentprice` &tplName=`New House for Rent` &first=``]]
sale [[AsSelectTv? &name=`condosaleprice` &tvName=`housesaleprice` &filter=`housesaleprice` &tplName=`New House for Sale` &first=``]]
</div><br />
<div>
<label>ref Number:</label><input id="[+as.inputId+]" class="cleardefault" type="text" name="search" value="" />
</div><br />
<br /><br />
<input id="[+as.submitId+]" type="submit" name="sub" value="Property Search" />
</fieldset>
</form>
</div>
<br />
`+]
I have run through all js libs included and they seem to be loaded fine, nothing of 404
There are a few example of good use ajax mode but not of 2 instances with advanced type with custom input on
http://www.evo.wangba.fr, http://www.evo.wangba.fr/index.php?id=188
There are also good examples of non ajax mode but with advanced mode
http://www.evo.wangba.fr/index.php?id=239
Looks like either snippet calls are wrong or config wrong. Any idea?