ASPX templates
Version 6.x > ASPX templates > How to get image show in smartsearch result? View modes: 
User avatar
Member
Member
hungquang_itsyad-yahoo.com - 9/28/2012 5:50:38 AM
   
How to get image show in smartsearch result?
Hi all

I using Root.SmartSearchResultsWithImages to show smartsearch result, but the code is:

<%-- Search result image --%>
<div style="float: left; border: solid 1px #eeeeee; width: 90px; height:90px; margin-right: 5px;">
<img src="<%# GetSearchImageUrl("~/App_Themes/Default/Images/CMSModules/CMS_SmartSearch/no_image.gif",90) %>" alt="" />
</div>

I want to get images from news, products.. to show in smartsearch result.

How to fix this code?

Thank!

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 9/28/2012 7:52:17 AM
   
RE:How to get image show in smartsearch result?
Hello,

Regrettably, I wasn't able to find a transformation wits such a name in our system, however you can try to use the default smart search transformation (ASCX):

<div style="margin-bottom: 30px;">
<%-- Search result image --%>
<div style="float: left; border: solid 1px #eeeeee; height:90px; width:90px; margin-right: 5px;text-align:center;">
<img src="<%# GetSearchImageUrl("~/App_Themes/Default/Images/CMSModules/CMS_SmartSearch/no_image.gif",90) %>" alt="" />
</div>
<div style="margin-left: 108px;">
<%-- Search result title --%>
<div>
<a style="font-weight: bold" href='<%# SearchResultUrl(true) %>'>
<%#SearchHighlight(CMS.GlobalHelper.HTMLHelper.HTMLEncode(CMS.ExtendedControls.ControlsHelper.RemoveDynamicControls(DataHelper.GetNotEmpty(Eval("Title"), "/"))), "<span style='font-weight:bold;'>", "</span>")%>
</a>
</div>
<%-- Search result content --%>
<div style="margin-top: 5px; min-height:40px">
<%#SearchHighlight(CMS.GlobalHelper.HTMLHelper.HTMLEncode(TextHelper.LimitLength(HttpUtility.HtmlDecode(CMS.GlobalHelper.HTMLHelper.StripTags(CMS.ExtendedControls.ControlsHelper.RemoveDynamicControls(GetSearchedContent(DataHelper.GetNotEmpty(Eval("Content"), ""))), false, " ")), 280, "...")), "<span style='background-color: #FEFF8F'>", "</span>")%><br />
</div>
<%-- Relevance, URL, Creattion --%>
<div style="margin-top: 5px;">
<%-- Relevance --%>
<div title="Relevance: <%#Convert.ToInt32(ValidationHelper.GetDouble(Eval("Score"),0.0)*100)%>%"
style="width: 50px; border: solid 1px #aaaaaa; margin-top: 7px; margin-right: 6px;
float: left; color: #0000ff; font-size: 2pt; line-height: 4px; height: 4px;">
<div style="<%# "background-color:#a7d3a7;width:"+ Convert.ToString(Convert.ToInt32((ValidationHelper.GetDouble(Eval("Score"),0.0)/2)*100)) + "px;height:4px;line-height: 4px;"%>">
</div>
</div>
<%-- URL --%>
<span style="color: #008000">
<%# TextHelper.BreakLine(SearchHighlight(SearchResultUrl(true),"<strong>","</strong>"),100,"<br />") %>
</span>
<%-- Creation --%>
<span style="padding-left:5px;;color: #888888; font-size: 9pt">
(<%# GetDateTimeString(ValidationHelper.GetDateTime(Eval("Created"), DateTimeHelper.ZERO_TIME), true) %>)
</span>
<hr/>
<%# GetSearchValue("ItemID").ToString() %>
<hr/>
</div>
</div>
<div style="clear: both">
</div>
</div>


Best regards,
Boris Pocatko

User avatar
Member
Member
hungquang_itsyad-yahoo.com - 9/28/2012 10:19:31 PM
   
RE:How to get image show in smartsearch result?

<div style="margin-bottom: 30px;">
<%-- Search result image --%>
<div style="float: left; border: solid 1px #eeeeee; height:90px; width:90px; margin-right: 5px;text-align:center;">
<img src="<%# GetSearchImageUrl("~/App_Themes/Default/Images/CMSModules/CMS_SmartSearch/no_image.gif",90) %>" alt="" />
</div>
<div style="margin-left: 108px;">
<%-- Search result title --%>
<div>
<a style="font-weight: bold" href='<%# SearchResultUrl(true) %>'>
<%#SearchHighlight(CMS.GlobalHelper.HTMLHelper.HTMLEncode(CMS.ExtendedControls.ControlsHelper.RemoveDynamicControls(DataHelper.GetNotEmpty(Eval("Title"), "/"))), "<span style='font-weight:bold;'>", "</span>")%>
</a>
</div>
<%-- Search result content --%>
<div style="margin-top: 5px; min-height:40px">
<%#SearchHighlight(CMS.GlobalHelper.HTMLHelper.HTMLEncode(TextHelper.LimitLength(HttpUtility.HtmlDecode(CMS.GlobalHelper.HTMLHelper.StripTags(CMS.ExtendedControls.ControlsHelper.RemoveDynamicControls(GetSearchedContent(DataHelper.GetNotEmpty(Eval("Content"), ""))), false, " ")), 280, "...")), "<span style='background-color: #FEFF8F'>", "</span>")%><br />
</div>
<%-- Relevance, URL, Creattion --%>
<div style="margin-top: 5px;">
<%-- Relevance --%>
<div title="Relevance: <%#Convert.ToInt32(ValidationHelper.GetDouble(Eval("Score"),0.0)*100)%>%"
style="width: 50px; border: solid 1px #aaaaaa; margin-top: 7px; margin-right: 6px;
float: left; color: #0000ff; font-size: 2pt; line-height: 4px; height: 4px;">
<div style="<%# "background-color:#a7d3a7;width:"+ Convert.ToString(Convert.ToInt32((ValidationHelper.GetDouble(Eval("Score"),0.0)/2)*100)) + "px;height:4px;line-height: 4px;"%>">
</div>
</div>
<%-- URL --%>
<span style="color: #008000">
<%# TextHelper.BreakLine(SearchHighlight(SearchResultUrl(true),"<strong>","</strong>"),100,"<br />") %>
</span>
<%-- Creation --%>
<span style="padding-left:5px;;color: #888888; font-size: 9pt">
(<%# GetDateTimeString(ValidationHelper.GetDateTime(Eval("Created"), DateTimeHelper.ZERO_TIME), true) %>)
</span>
<hr/>
<%# GetSearchValue("ItemID").ToString() %>
<hr/>
</div>
</div>
<div style="clear: both">
</div>
</div>



In line:
<img src="<%# GetSearchImageUrl("~/App_Themes/Default/Images/CMSModules/CMS_SmartSearch/no_image.gif",90) %>" alt="" />

Image show in my smart search result is always no_image.gif but my news, products have teaser images.
How to get search result image?

Thank!

P/s: I can't speak English fluently, if you don't understand, I will snap my desktop to show you.

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 10/1/2012 5:41:38 AM
   
RE:How to get image show in smartsearch result?
Hello,

It is working fine on my end. I am using the mentioned transformation with the following code:

<img src="<%# GetSearchImageUrl("~/App_Themes/Default/Images/CMSModules/CMS_SmartSearch/no_image.gif",90) %>" alt="" />


And I have the teaser image displayed in my search results for the Menu item (page) document type by default:

User image

This also works by default for articles:

User image

You need to make sure, that the Image field is set correctly to point to the field containing the teaser image for the given document. This can be done in Site manager / Development / Document types / <your document type> / Search fields:

User image

Best regards,
Boris Pocatko

User avatar
Member
Member
hungquang_itsyad-yahoo.com - 10/1/2012 10:35:41 AM
   
RE:How to get image show in smartsearch result?
THank

User avatar
Member
Member
hungquang_itsyad-yahoo.com - 10/2/2012 5:01:12 AM
   
RE:How to get image show in smartsearch result?
Thank Boris Pocatko,

How can i paging smartsearch result if there are too many results?

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 10/2/2012 10:38:50 AM
   
RE:How to get image show in smartsearch result?
Hello,

You can use the UniPager web part. You only need to specify the Target control name of the Search results web part.

Best regards,
Boris Pocatko

User avatar
Member
Member
hungquang_itsyad-yahoo.com - 10/2/2012 9:29:21 PM
   
RE:How to get image show in smartsearch result?
Thank,

But i can't see UniPager web part, Target control name of the Search results web part.
Can't you show me documents about that?


User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 10/3/2012 2:28:44 AM
   
RE:How to get image show in smartsearch result?
Hello,

I am sorry, the web parts code name is UniPager, but the web part is called Universal Pager in the web parts listing.

Best regards,
Boris Pocatko

User avatar
Member
Member
hungquang_itsyad-yahoo.com - 10/3/2012 4:45:44 AM
   
RE:How to get image show in smartsearch result?
Thank Boris Pocatko,

When I using this webpart


<%@ Register Src="~/CMSWebParts/SmartSearch/SearchResults.ascx" TagName="SearchResults" TagPrefix="uc1"%>
<%@ Register Src="~/CMSWebParts/Viewers/Basic/UniPager.ascx" TagName="UniPager" TagPrefix="uc2"%>


<uc1:SearchResultsrunat="server" ID="SearchResults" TransformationName="cms.root.smartsearchresultswithimages" Indexes="bcc2" NoResultsText="No result"/>
<hr />
<uc1:UniPager runat="server" ID="UniPager" TargetControlName="SearchResults" PageSize="2"/>


but the result only display on per page, can't show two result per page (PageSize="2").
What's my problem? How to fix it?

Thank!

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 10/5/2012 9:50:01 AM
   
RE:How to get image show in smartsearch result?
Hello,

If you are using the search results web part directly, you should able to page it with setting the PageSize property:

<uc1:SearchResults PageSize="2" ... />


Best regards,
Boris Pocatko

User avatar
Member
Member
hungquang_itsyad-yahoo.com - 10/7/2012 9:42:51 PM
   
RE:How to get image show in smartsearch result?


<uc1:SearchResultsrunat="server" ID="SearchResults" TransformationName="cms.root.smartsearchresultswithimages" Indexes="bcc2" NoResultsText="No result" PageSize="2"/>



If i setting PageSize property = 2, the result only show 2 results, not paging.

how to paging?

thank!

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 10/21/2012 7:01:28 AM
   
RE:How to get image show in smartsearch result?
Hello,

I am sorry for confusing. The UniPager does not work with Search results on ASPX templates in version 6 (it only works in version 7). You can use the built-in pager within the Search results web part but you need to specify transformations for pager, for example:

<uc1:SearchResults runat="server" ID="SearchResults" TransformationName="cms.root.smartsearchresultswithimages" Indexes="CorporateSite.Default" NoResultsText="No result" PagesTemplate="CorporateSite.Transformations.Pager-Pages" QueryStringKey="page" PageSize="1" GroupSize="1" CurrentPageTemplate="CorporateSite.Transformations.Pager-CurrentPage" SeparatorTemplate="CorporateSite.Transformations.Pager-PageSeparator" FirstPageTemplate="CorporateSite.Transformations.Pager-FirstPage" LastPageTemplate="orporateSite.Transformations.Pager-LastPage" PreviousGroupTemplate="CorporateSite.Transformations.Pager-PreviousGroup" NextGroupTemplate="CorporateSite.Transformations.Pager-NextGroup" PreviousPageTemplate="CorporateSite.Transformations.Pager-PreviousPage" NextPageTemplate="CorporateSite.Transformations.Pager-NextPage" LayoutTemplate="CorporateSite.Transformations.Pager-Layout"  />

Best regards,
Helena Grulichova