0
我希望能夠在某個目錄內進行搜索。例如。可以說用戶點擊了網站頂部的「不同類型的火車」鏈接。然後,該頁面將列出不同類型的列車,並帶有搜索框。我希望用戶在搜索框中鍵入的任何內容僅用於搜索「火車類型」部分中的頁面 - 任何在/sitecore/content/LOTW/Home/trains
之內的內容以及網站上的其他任何頁面。我目前使用:使用sitecore搜索搜索特定文件夾
protected void searchIcon_Click(object sender, EventArgs e)
{
PerformSearch();
}
private void PerformSearch()
{
/* Changed from Shared Source, to use different path finding, and context database */
Item pointerItem = Sitecore.Context.Database.SelectSingleItem("/sitecore/content/LOTW/Global/Settings/Config/Pointers/Search Results");
if (pointerItem != null)
{
Item results = Sitecore.Context.Database.GetItem(new ID(pointerItem["Item"]));
if (results != null)
{
string results_url = LinkManager.GetItemUrl(results) + "?search=" + Server.UrlEncode(search.Text);
Response.Redirect(results_url);
}
else
{
search.ForeColor = Color.Red;
search.Text = "Unable to find results item";
}
}
}
這反而搜索整個網站。我對Sitecore中的搜索一無所知,所以我有點失落!
我有點困惑。您發佈的代碼似乎只處理查找搜索頁面並重定向到它。它不是實際的搜索代碼。不過,我建議你爲每個部分創建獨特的索引來搜索和使用[高級數據庫爬行器](http://trac.sitecore.net/AdvancedDatabaseCrawler/) – 2012-01-06 13:45:33