Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > Transformation changes to the search results View modes: 
User avatar
Member
Member
sasdaman - 4/9/2009 4:58:19 PM
   
Transformation changes to the search results
Hi,

I wish to use these transformation expressions to show the text of my main text webpart on each page as part of the search results:
<%# GetEditableValue("editabletext3") %>
<%# LimitLength("Some example long text", 10 , "...") %>

The catch though is the web part content is very long so I only want to show say the first 50 characters. What I was hoping was I would be able to use both expressions within each other so to get the effect of getting the webpart value but then limiting the length that displays. So far I can only achieve one or the other. Is there anyway I achieve this??

Kind regards,
Sahus Pilwal

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 4/15/2009 7:40:33 AM
   
RE:Transformation changes to the search results
Hi Sahus,

Could you please confirm you have tried:
<%# LimitLength(GetEditableValue("editabletext3"), 50 , "...") %>

If so, could you please specify in more detail how it behaved after that? Did it throw any error?

Best Regards,
Martin Dobsicek

User avatar
Member
Member
sasdaman - 4/15/2009 12:35:28 PM
   
RE:Transformation changes to the search results
Hi Martin,

No I was using the wrong syntax so your code worked. However now it seems to break my design which is strange. When I take the code back out of the design then it works again. Has this nesting transformation type been tested before?? I don't think its closing a div somewhere along the lines properly. In fact after comparing the rendered HTML using the above syntax it causes the rendered HTML to remove 3 Ending </divs> for the search web part which are required. This of course breaks the design. I've tried to use HTML envelops for Content after: to add three additional closing divs but this doesnt work. Any ideas what the problem could be?

Many thanks,

Sahus

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 4/22/2009 8:35:56 AM
   
RE:Transformation changes to the search results
Hi Sahus,

the GetEditableValue method returns HTML code from editable region so the LimitLength method in your case returns first 50 characters of HTML code which may cause that closing tags for <div> tags from your editable region are not generated. You could eventually try to use sample code bellow to strip the tags so only plain text without HTML markup will be trimmed and displayed:
<%# LimitLength(CMS.GlobalHelper.HTMLHelper.StripTags(GetEditableValue("editabletext3")), 50 , "...") %>

Best Regards,
Martin Dobsicek

User avatar
Member
Member
sasdaman - 4/22/2009 9:15:44 AM
   
RE:Transformation changes to the search results
Hi Martin,

That worked a treat. Thanks very much for your help.

Kind regards,

Sahus Pilwal

User avatar
Member
Member
lwhittemore-emh - 6/17/2013 12:24:23 PM
   
RE:Transformation changes to the search results
I am trying to do this on my site as well but it is not getting the editable text field at all.

User avatar
Member
Member
ctaleck IPAGlobal - 4/23/2009 2:49:47 PM
   
RE:Transformation changes to the search results
Perhaps my code will give you some ideas. Under Site Manager > Development > Document types > CMS.Root > Transformations > SearchResults, I have this:

<div class="SearchResult">
<div class="ResultTitle">
<a href="<%# GetDocumentUrl()%>" title="Path: <%# Eval("DocumentNamePath") %>"><img class="ResultIcon" border="0" src="~/App_Themes/IPAGlobalGreenSite/Images/DocumentIcons/<%# Eval("ClassName") %>.gif" title="<%# Eval("ClassDisplayName") %>"><%# Eval("SearchResultName") %></a>
<span class="ResultDate">(<%# FormatDateTime(Eval("DocumentModifiedWhen"),"d-MMM-yyyy h:mm:ss tt") %>)</span>
</div>
<div class="ResultBody">
<div class="ResultDescription"><%# LimitLength(StripTags(GetEditableValue("ContentText")),200," ... ") %></div>
<div class="ResultDescription"><%# LimitLength(StripTags(Eval("DocumentPageDescription")),200," ... ") %></div>
<div class="ResultDescription"><%# LimitLength(StripTags(Eval("JobSummary")),200," ... ") %></div>
<div class="ResultDescription"><%# LimitLength(StripTags(Eval("NewsSummary")),200," ... ") %></div>
<div class="ResultDescription"><%# LimitLength(StripTags(Eval("EventSummary")),200," ... ") %></div>
<div class="ResultDescription"><%# LimitLength(StripTags(Eval("OfficeDescription")),200," ... ") %></div>
<div class="ResultDescription"><%# LimitLength(StripTags(Eval("ArticleText")),200," ... ") %></div>
<div class="ResultDescription"><%# LimitLength(StripTags(Eval("PublicationText")),200," ... ") %></div>
<div class="ResultTags"><%# Eval("DocumentTags") %></div>
</div>
</div>


This shows an icon, title, modified date, a 200 character preview of every document type I am using, and a tag list in my search results. Here is a sample.

User avatar
Member
Member
sasdaman - 4/27/2009 9:38:28 AM
   
RE:Transformation changes to the search results
Hi,

I like you use of the transformations. I'm trying to implement using the index transformation & document size as a ad-hoc transformation.

So I can index the results as 1,2,3,4 and so on & include the document file size.

I will post details soon.

Cheers,
Sahus