English 中文(简体)
Kentico CMS search results
原标题:

How do I change the Kentico CMS search settings so as to display a part of text from search results as in Google? Presently it shows only the path in the results.

最佳回答

It depends on how you have your search setup really.

At the page level if you are using the Portal Engine model, which the majority of people use now, you have to check the Widget that you are using, basically it boils down to a regular search or Smart Search.

If your using the ASPX Template model you may have to open up your source for the page and see which usercontrol file your using from ~/CMSWebParts/Search/ or ~/CMSWebParts/SmartSearch/

Once you figure out which user control you are using it s a matter of inspecting the Transformation that it uses. Most likely you ll be using one of the following:

CMS.Root.SearchResults CMS.Root.SmartSearchResults CMS.Root.SmartSearchResultsWithImages

Click on Edit Transformation and check out which field is inside the Call to SearchHighlight, normally, "Content". Then you know it s pulling from the main content of the document. I ve also seen this be tied to a different field like "Title" or "Caption". But the default is "Content".

If you still dont see results with part of the text, make sure you have a Smart Search Index setup, found in CMSSiteManager -> Administation -> Smart Search. If you don t see your site in the Index list then you need to add one. Make sure you rebuild it and optimize it (click edit on the row to get to those options). After that is all rebuilt then you should see the text appear under the result.

问题回答

One thing to note, is that as @jao has mentioned, this only takes the first 280 characters of the content of the page. If you re matching search text doesn t happen to be in the first 280 characters, then no highlighting will occur.

try the following in your search result transformation:

<p>
<%# SearchHighlight(HTMLHelper.HTMLEncode(TextHelper.LimitLength(HttpUtility.HtmlDecode(HTMLHelper.StripTags(GetSearchedContent(DataHelper.GetNotEmpty(Eval("Content"),"")),false, " ")), 280, "...")),"<span style="background-color: #FEFF8F">","</span>") %>
</p>

This will show the first 280 characters from your content, with the search terms highlighted.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签