我在表達式引擎搜索中遇到了一些問題!我有一個很好的下拉式表單設置,但是我需要在此搜索表單中添加一個OPTIONAL關鍵字字段。任何想法我會如何與我當前的代碼做到這一點:Expression Engine高級搜索 - 搜索關鍵字時出現問題
主要形式代碼:
<form method="post" action="/properties/search-results/">
<p>Keywords:</p>
<input id="keywords" type="text" name="keywords"/>
<p>Town:</p>
<select id="town" name="cat[]" multiple="multiple">
<option value="" selected="selected">Any</option>
{exp:channel:categories channel="property" style="linear" category_group="1"}
<option value="{category_id}">{category_name}</option>
{/exp:channel:categories}
</select>
<p>Property Type:</p>
<select id="propertyType" name="cat[]">
<option value="" selected="selected">Any</option>
{exp:channel:categories channel="property" style="linear" category_group="2"}
<option value="{category_id}">{category_name}</option>
{/exp:channel:categories}
</select>
<input style="margin-top:20px; width: 100px;" type="submit" name="submit" value="Search"/>
</form>
搜索的結果模板:
<?php
// Grab the categories selected from the $_POST
// join them with an ampersand - we are searching for AND matches
$cats = "";
foreach($_POST['cat'] as $cat){
// check we are working with a number
if(is_numeric($cat)){
$cats .= $cat."&";
}
}
// strip the last & off the category string
$cats = substr($cats,0,-1);
?>
{exp:channel:entries channel="property" dynamic="on" category="<?php echo($cats);?>" orderby="date" sort="asc"}
我需要的關鍵字字段搜索{ title}我的參賽作品!
感謝您的幫助!
難道沒有人知道這??? – kala233