Dynamic content in SearchText
-
-
Johan, have you found this with the CMS 6R2 integration or 7 integration?
Reason I'm asking is because I can see this happening for 6R2 but for 7 dynamic content *should* be rendered and indexed as XhtmlStrings are indexed as the return value of ToHtmlString(AnonymousPrincipalDude).
-
6R2 Joel. I guess some Regex-magic can get rid of the curly braces. I've already overridden SearchText and added some own content, so it wouldn't be a big effort to fix that.
But I thought I'd check with you guys first and see if you had a solution to the problem.
-
Hi!
Not sure if it's related but there is a bug that the page property dynamic content does not handle rendering when calling prop.ToString() in EPiServer 7.
-
Ok, here is my solution... first remove the default implementation of SearchText and then add our.
SearchClient.Instance.Conventions.ForInstancesOf<PageData>() .ExcludeField(page => page.SearchText()) // Exclude the default SearchText .IncludeField(page => page.SearchText(true)); // Include our extened SearchText
And the actual implementation of our SearchText
public static string SearchText(this PageData page, bool extended) { StringBuilder content = new StringBuilder(); // Removes dynamic content plugins string text = Regex.Replace(page.SearchText(), @"\{\w+\}", string.Empty); content.AppendLine(text); // Add extra content from "tab pages" foreach (var tab in DataFactory.Instance.GetChildren(page.PageLink)) { if (tab.PageTypeID == Settings.Instance.TabPageTypeID) { content.AppendLine(tab["TabHeading"] as string); content.AppendLine(tab["TabBody"] as string); } } return content.ToString().StripHtml(); }
Hi,
Dynamic content isn't renderd in SearchText extension. I guess that's fine. The span surrounding the DC is removed but not the actual content in it. So if a page has the PagePropertyPlugin and fetches a property from another page the text "{PagePropertyPlugin}" gets indexed. I think this should be removed also.