I have a couple of custom document types that use custom queries to display the detail information. They are grouped under parent documents that use a URL redirect to remove the parent from the NodeAliasPath
Example:
/Media/NewsRoom/News/This-Is-My-Article.aspx
becomes:
/Media/NewsRoom/This-Is-My-Article.aspx
When these document types are retreived in the search results they obviously have the full alias path. I am working on the transformation for my results page and would like to add some text replacement so the links follow the correct format. What I am looking for is a best practice way of doing so. My current intent is this:
<script runat="server">
protected override void OnDataBinding(EventArgs e)
{
/* Conditional Replacement Code Here */
}
</script>
<div style="margin-bottom: 30px;">
<div style="float: left; border: solid 1px #eeeeee; width: 90px; height:90px; margin-right: 5px;">
<img src="<%# GetSearchImageUrl("/CMSModules/CMS_SmartSearch/no_image.gif",90) %>" alt="" />
</div>
<div style="margin-left: 108px;">
<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>
<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>
<div style="margin-top: 5px;">
<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>
<span style="color: #008000">
<%# TextHelper.BreakLine(SearchHighlight(SearchResultUrl(true),"<strong>","</strong>"),100,"<br />") %>
</span>
<span style="padding-left:5px;;color: #888888; font-size: 9pt">
(<%# GetDateTimeString(ValidationHelper.GetDateTime(Eval("Created"), DateTimeHelper.ZERO_TIME), true) %>)
</span>
</div>
</div>
<div style="clear: both">
</div>
</div>
In the script segment I am thinking I will use a case statement to set the URL value for a hyperlink control which would replace the normal link and <%# SearchResultUrl(true) %>. Does this seem like a good approach?
Is OnDataBinding the correct method to use? Any help would be appreciated.