How do I get accurate entry paths in Expression Engine search results?
I am working to implement advanced search on a site and need some help getting more accurate paths to entries in the search results page.
I am using a modified advanced search form:
{exp:search:advanced_form result_page="search/advanced_results"}
<fieldset class="fieldset">
<legend>{lang:search_by_keyword}</legend>
<input type="text" class="input" maxlength="100" size="40" name="keywords" style="width:100%;" />
<div class="default">
<select name="search_in">
<option value="titles" selected="selected">{lang:search_in_titles}</option>
<option value="entries" selected="selected">{lang:search_in_entries}</option>
</select>
</div>
<div class="default">
<select name="where">
<option value="exact" selected="selected">{lang:exact_phrase_match}</option>
<option value="any">{lang:search_any_words}</option>
<option value="all" >{lang:search_all_words}</option>
<option value="word" >{lang:search_exact_word}</option>
</select>
</div>
</fieldset>
<div class="defaultBold">{lang:channels}</div>
<select id="channel_id" name='channel_id[]' class='multiselect' size='15' multiple='multiple' onchange='changemenu(this.selectedIndex);'>
{channel_names}
</select>
<div class="defaultBold">{lang:categories}</div>
<select name='cat_id[]' size='18' class='multiselect' multiple='multiple'>
<option value='all' selected="selected">{lang:any_category}</option>
</select>
<div class='searchSubmit'>
<input type='submit' value='Search' class='submit' />
</div>
{/exp:search:advanced_form}
</body>
and the standard search results code:
<table border="0" cellpadding="6" cellspacing="1" width="100%">
<tr>
<th>{lang:title}</th>
<th>{lang:excerpt}</th>
<th>{lang:author}</th>
<th>{lang:date}</th>
<th>{lang:total_comments}</th>
<th>{lang:recent_comments}</th>
</tr>
{exp:search:search_results switch="resultRowOne|resultRowTwo"}
<tr class="{switch}">
<td width="30%" valign="top"><b><a href="{auto_path}">{title}</a></b>开发者_Python百科;</td>
<td width="30%" valign="top">{excerpt}</td>
<td width="10%" valign="top"><a href="{member_path='member/index'}">{author}</a></td>
<td width="10%" valign="top">{entry_date format="%m/%d/%y"}</td>
<td width="10%" valign="top">{comment_total}</td>
<td width="10%" valign="top">{recent_comment_date format="%m/%d/%y"}</td>
</tr>
{/exp:search:search_results}
</table>
The only problem is that the {auto_path} is anything but accurate, does not link to the entry and basically tries to piggyback off the home page. Is there a way secure more accurate paths? I know Google Search can do it.
Thanks!
Admin → Channel Administration → Channels → Edit Preferences → Path Settings. There you enter the base URL for your auto_path
or id_auto_path
.
So entering /news/entry/ would yield /news/entry/my-new-url-title in your search results.
The {auto_path}
variable in the Search Results Tag is automatically be determined by the Search Results URL preference setting for the channel in Channel Management.
You can find this preference in the Control Panel at: Admin > Channel Administration > Channel Preferences:
精彩评论