Change the Title of search results to DocumentPageTitle

Gideon Gontor asked on April 4, 2019 13:38

I need help with changing the search result Title to the metadata DocumentPageTitle from the following transformation.

<%-- Search result image --%>
" alt="" />
<%-- Search result title --%> <%-- Search result content --%>
<%#SearchHighlight(HTMLHelper.HTMLEncode(TextHelper.LimitLength(HttpUtility.HtmlDecode(HTMLHelper.StripTags(CMS.Base.Web.UI.ControlsHelper.RemoveDynamicControls(GetSearchedContent(DataHelper.GetNotEmpty(Eval("Content"), ""))), false, true, " ", "@", "")), 280, "...")), "", "")%>
<%-- Relevance, URL, Creattion --%>
<%-- Relevance --%>
%" 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;">
">
<%-- URL --%> <%# TextHelper.BreakLine(SearchHighlight(SearchResultUrl(),"",""),75,"
") %>
<%-- Creation --%> <%# GetDateTimeString(ValidationHelper.GetDateTime(Eval("Created"), DateTimeHelper.ZERO_TIME), true) %>
    </div>
    <div style="clear: both">
    </div>
</div>

Correct Answer

Juraj Ondrus answered on April 4, 2019 14:01

Or, you can also change the source field in the page type definition. There are some default index fields, and you can set source fields for them (Sample screen shot). So, this way you can have different fields set for different page types. More details can be found in our documentation.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Roman Hutnyk answered on April 4, 2019 13:50

Have you tried to change Eval("Title") to Eval("DocumentPageTitle") in the following line of code?

                <%#SearchHighlight(HTMLHelper.HTMLEncode(CMS.Base.Web.UI.ControlsHelper.RemoveDynamicControls(DataHelper.GetNotEmpty(Eval("Title"), "/"))), "
1 votesVote for this answer Mark as a Correct answer

Gideon Gontor answered on April 4, 2019 14:57

Hi Roman/Juraj

I changed the title field on the page type to DocumentPageTitle save and rebuild the index, it works like magic. I didn't make any changes to the transformation I left the title as it is.

Thanks

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.