0
我使用SOLR獲取我的構面,一切正常,甚至過濾器查詢都是正確的。分面搜索/分層導航,結果過濾
我很努力的過濾器顯示的PHP部分。
使用有源濾波器的方面看起來像這樣。但我想實現這些鏈接...
Manufacturers
-------------
[] BMW (/page?q=cars&manufacturer=Audi&manufacturer=Mercedes&manufacturer=BMW&model=BMW - X5&model=Mercedes - C)
[x] Audi (/page?q=cars&manufacturer=Mercedes&model=BMW - X5&model=Mercedes - C)
[x] Mercedes(/page?q=cars&manufacturer=Audi&manufacturer=Mercedes&model=BMW - X5&model=Mercedes - C)
[] Seat(/page?q=cars&manufacturer=Audi&manufacturer=Mercedes&manufacturer=Seat&model=BMW - X5&model=Mercedes - C)
[] Skoda (/page?q=cars&manufacturer=Audi&manufacturer=Mercedes&manufacturer=Skoda&model=BMW - X5&model=Mercedes - C)
Model
-------------
[] BMW - E49 (/page?q=cars&manufacturer=Audi&manufacturer=Mercedes&model=BMW - X5&model=Mercedes - Cmodel=BMW - E49)
[] BMW - X3 (/page?q=cars&manufacturer=Audi&manufacturer=Mercedes&model=BMW - X5&model=Mercedes - C&model=BMW - X3)
[x] BMW - X5 (/page?q=cars&manufacturer=Audi&manufacturer=Mercedes&model=Mercedes - C)
[] Mercedes - A (/page?q=cars&manufacturer=Audi&manufacturer=Mercedes&model=Mercedes - C&model=BMW - X5&model=Mercedes - A)
[] Mercedes - B (/page?q=cars&manufacturer=Audi&manufacturer=Mercedes&model=Mercedes - C&model=BMW - X5&model=Mercedes - B)
[x] Mercedes - C (/page?q=cars&manufacturer=Audi&manufacturer=Mercedes&model=BMW - X5)
[] Mercedes - E (/page?q=cars&manufacturer=Audi&manufacturer=Mercedes&model=Mercedes - C&model=BMW - X5&model=Mercedes - E)
[] Mercedes - S (/page?q=cars&manufacturer=Audi&manufacturer=Mercedes&model=Mercedes - C&model=BMW - X5&model=Mercedes - S)
我有很大的困難,以獲得當前活動的選擇,當我點擊已經選擇的項目,將其從URL字符串中刪除。
函數我用來獲取查詢字符串。
function getFilter() {
$query = explode('&', $_SERVER['QUERY_STRING']);
$params = array();
foreach($query as $param) {
list($name, $value) = explode('=', $param);
$params[urldecode($name)][] = urldecode($value);
}
return $params;
}
上述功能給了我這樣的事情:
(
[q] => Array
(
[0] => cars
)
[manufacturer] => Array
(
[0] => Audi
[1] => Mercedes
)
[model] => Array
(
[0] => BMW - X5
[1] => Mercedes - C
)
)
之後,我會盡力讓所選擇的項目,如果在小環的值等於一個方面刪除,但我我的頭不能包裹它。
foreach($newFacetArray as $val => $count) {
if(strlen($val) != 0) {
if(isset($activeFilters[$value])) {
if(in_array($val,$activeFilters[$value])) {
foreach($activeFilters[$value] as $af) {
if($af == $val) {
$as = array_search($val,$activeFilters[$value]);
unset($activeFilters[$value][$as]);
} else {
if($af != $val) {
$activeFilters[$value][] = $val;
}
}
}
}
}
$url = http_build_query($activeFilters);
#$url = $_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'].'&'.(($value == 'manufacturerName')?$value.'[]':$value).'='.$val;
echo '<li class="list-group-item"><a class="attribute-loader" href="'.$url.'"><input type="checkbox" name="'.$value.'" '.$facetSearch->verifyIfChecked($_GET,$val).'/> ' . $val . ' <span class="pull-right">'.$count.'</span></a></li>';
}
}