Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Smart Search Transformations View modes: 
User avatar
Certified Developer v7
Certified  Developer v7
erik.weiss-nerdery - 12/28/2012 5:09:34 PM
   
Smart Search Transformations
Hello--

Is it possible to have different transformations in the Smart Search Results based on the document type?

Thanks,
Erik

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 12/30/2012 2:36:56 PM
   
RE:Smart Search Transformations
In the Transformation section on the webpart, use a macro that would set the value of the transformation based on the document type (class name) like so:
CurrentDocument.ClassName == "Your.ClassName"

User avatar
Certified Developer v7
Certified  Developer v7
Erik - 1/2/2013 2:48:18 PM
   
RE:Smart Search Transformations
I'm not sure what you're getting at.

I tried this in the Transformation section, but all my search results are blank:
{%ClassName%}.SearchResults

User avatar
Certified Developer v7
Certified  Developer v7
Erik - 1/2/2013 2:55:37 PM
   
RE:Smart Search Transformations
Looks like {%ClassName%} always resolves as a CMS.MenuItem, instead of the actual type of document is being returned from the search.

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 1/7/2013 6:09:28 AM
   
RE:Smart Search Transformations
Hello,

It is not currently possible to use different transformation for different document types in a repeater, if you are not talking about the selected item transformation. This is a general issue with the default .NET repeater control and it is used as the base control for our Kentico repeaters.

However, you can create for example custom transformation function which would output html code according for each repeater item according to current document type.

A second possible approach is described in following forum thread, however it is not recommended because the performance of this approach isn't optimal.

Additional information on customizing the search results can be found in our Knowledge base section.

Best regards,
Boris Pocatko

User avatar
Certified Developer v7
Certified  Developer v7
Erik - 1/14/2013 4:36:43 PM
   
RE:Smart Search Transformations
Our ultimate solution was to capture the ClassName on the OnDataBinding in the top of the transformation:
<script runat="server">
public String ClassName { get; set; }
protected override void OnDataBinding(EventArgs e) {
base.OnDataBinding(e);

ClassName = GetSearchValue("ClassName") as string;
}
</script>

Then have conditional statements that compared against the property we captured:
<% if ("CMS.Smartphone".Equals(ClassName)) { %>