Dynamic content in SearchText

Vote:
 

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 "" gets indexed. I think this should be removed also.

#65814
Feb 11, 2013 13:28
Vote:
 

Good point. I will look into that.

#65820
Feb 11, 2013 14:40
Vote:
 

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).

#65832
Feb 11, 2013 19:09
Vote:
 

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.

#65836
Feb 12, 2013 0:40
Vote:
 

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.

#65837
Feb 12, 2013 7:42
Vote:
 

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();
}

    

#65864
Feb 12, 2013 15:10
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.