1

使用同上,我创建了一个产品目录。我现在希望添加搜索和过滤选项。有人知道最好的方法吗?我似乎找不到一个好的插件。

我正在运行 ModX Evolution 1.0.6

4

1 回答 1

0

如果有人感兴趣,我放弃并自己制作:

更新了完整的代码

请随时要求我澄清任何事情或添加更改或改进。

请注意,我必须解决一个问题——您不能结合电视的搜索词来进行非常明确的搜索。我仍然会为此努力

//TV FILTERS
$sql = 'SELECT DISTINCT `contentid` FROM `modx_site_tmplvar_contentvalues`';
$where = array();
//ADD THE VARIABLES YOU WANT TO SEARCH TV's WITH BELOW
if ($searchlocation !== 'Any') $where[] = '`value` LIKE "%'.$searchlocation.'%"';
if ($searchmake !== 'Any')  $where[] = '`value` LIKE "%'.$searchmake.'%"';
if ($searchtype !== 'Any') $where[] = '`value` LIKE "%'.$searchtype.'%"';
if (count($where) > 0) {
  $sql .= ' WHERE '.implode(' OR ', $where);
} else {
  // OPTIONAL
  // Error out; must specify at least one!
}

$tvqresult = mysql_query($sql);
$num_rowstvq = mysql_num_rows($tvqresult);
while ($rowtvq = mysql_fetch_array($tvqresult)) {
$contid =  $rowtvq['contentid'];

//MAIN QUERY RETRIEVES RESOURCE - TEMPLATE LIMITS SEARCH TO PARTICULAR TYPE THAT WILL BE USED IN DITTO
$mainsql = 'SELECT * FROM `modx_site_content` WHERE `id` = ' . $rowtvq['contentid'] . '  AND `template` = 12';

$resultmain = mysql_query($mainsql);
$num_rowsmain = mysql_num_rows($resultmain);
if (!$resultmain) {
continue;
}
elseif ($num_rowsmain == 0){
echo "Sorry - nothing matches your search";
}

else {
while ($row = mysql_fetch_array($resultmain )) {
  echo "[[Ditto? &parents=`134` &documents=" . $row['id'] . " &tpl=`usedtempchunk`]]";
}//END MAIN LOOP

}//END MAIN ELSE

}//END TV WHILE LOOP
?>
于 2012-09-13T02:31:20.590 回答