ASPX templates
Version 3.x > ASPX templates > Customizing the search results View modes: 
User avatar
Member
Member
gary.swanson-number41media - 10/15/2008 12:06:24 PM
   
Customizing the search results
Hi,

We have a client who wants to have the search results on their site bring back some text that surrounds the text they were searching for much like google search results. I would like to know if this is possible.

Thanks

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 10/16/2008 2:52:45 AM
   
RE:Customizing the search results
Hi,

Let's say that you have for each document type you want to search in some field with some summary, e.g. NewsSummary for news type and ArticleSummary for article type. In these fields is placed a short description.

Now, could you please use in the search results transformation this function GetColumnNAme(string column_names, bool allowEmptyColumn):

<%# GetColumnName("NewsSummary;ArticleSummary", false) %>

This should return the content of appropriate columns.

I hope it will help.


Best Regards,
Juraj Ondrus

User avatar
Member
Member
patrickhiston - 9/28/2009 6:07:00 AM
   
RE:Customizing the search results
I am trying to do a similar thing but cannot get it to work, any advice would be appreciated.

I have some custom knowledge base article document types, and when I carry out a search on these using the CMS search web-parts, the results are returned using the standard search results transformation:

Name
Path

Name
Path

etc

However, each of my knowledge base articles has a summary field defined against it, which I don't seem to be able to access from the transformation.

I would like it to appear as:

Name
Path
Summary

Name
Path
Summary

etc

My transformation is as follows:

<div class="SearchResult">
<div class="ResultTitle">
<a href="<%# GetDocumentUrl()%>"><%# IfEmpty(Eval("SearchResultName",true), "/", Eval("SearchResultName",true)) %></a>
</div>
<div class="ResultPath">
Path: <%# Eval("DocumentNamePath",true) %><br />
Path: <%# Eval("Summary", true) %><br />
</div>
</div>

I am guessing this is because it doesn't know which table it is looking in to retrieve the 'Summary'. How should I go about this?

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 9/29/2009 1:36:53 AM
   
RE:Customizing the search results
Hi,

If you are using older version than 4.1, you will need to develop custom search provider where you will alter the returned dataset of results.

I would recommend to upgrade to the 4.1 version where the new Smart Search was added and it allows to achieve your need very easy with many other improvements.

Best Regards,
Juraj Ondrus

User avatar
Member
Member
mike.deck-rescentris - 2/15/2010 1:42:10 PM
   
RE:Customizing the search results
I have my search results exactly as I'd like them but the returned path seems to always be truncated.

Here's what I have:
<a href="<%# GetDocumentUrl( ) %>"><%# Eval("SearchResultName") %></a>


The returned document title is correct and is a link, but the link truncates any returned document path and appends aspx to the cut off filename. Instead of taking me to the found document, it refreshes the page and now only shows me the search result that I'm trying to get to.

Any ideas?

In case it helps, here's my full search result transformation:

<li>
<div class="SearchResult">
<div class="ResultTitle">

<a href="<%# GetDocumentUrl( ) %>"><%# Eval("SearchResultName") %></a>
<br>
<span style="font-size: x-small;">
<span class="ResultDate">(<%# FormatDateTime(Eval("DocumentModifiedWhen"),"d-MMM-yyyy") %>)</span>
</div>
<span style="font-size: x-small;">
<div class="ResultBody">
<div class="ResultDescription"><%# LimitLength(StripTags(GetEditableValue("ContentText")),400," ... ") %></div>
<div class="ResultDescription"><%# LimitLength(StripTags(Eval("DocumentPageDescription")),400," ... ") %></div>
<div class="ResultDescription"><%# LimitLength(StripTags(Eval("JobSummary")),400," ... ") %></div>
<div class="ResultDescription"><%# LimitLength(StripTags(Eval("NewsSummary")),400," ... ") %></div>
<div class="ResultDescription"><%# LimitLength(StripTags(Eval("EventSummary")),400," ... ") %></div>
<div class="ResultDescription"><%# LimitLength(StripTags(Eval("OfficeDescription")),400," ... ") %></div>
<div class="ResultDescription"><%# LimitLength(StripTags(Eval("ArticleText")),400," ... ") %></div>
<div class="ResultDescription"><%# LimitLength(StripTags(Eval("PublicationText")),400," ... ") %></div>
<div class="ResultTags"><%# Eval("DocumentTags") %></div></span>
</div>
</div>

</li>
<br>

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 2/23/2010 7:28:15 AM
   
RE:Customizing the search results
Hello,

Could you please try to use following code in your transformation instead:


<a href='<%# SearchResultUrl(true) %>'>
...
</a>


Best Regards,

Martin Dobsicek