Views: 1417
Number of votes: 1
Average rating:

Search and property with backing type

I guess that everybody is familiar with the custom property for editing the metakeyword property in the Alloy templates.

I assume that there are at least a few EPiServer 7 sites out there that uses it, and also doesn’t use Find or any other soution for handling search.

We discovered that if using that custom property which is nice for the editors, have the drawback that the keywords entered isn’t searchable (I guess it doesn’t get indexed) even if you decorate the property with the [Searchable] attribute.

Luckily it’s an easy fix. Just override the ToString method in the backing type like below and the keywords will be searchable.

public override string ToString()
    if (Value != null)
        return string.Join(",", List);
        return string.Empty;

Jan 24, 2014

Santosh Achanta
( By Santosh Achanta, 2/17/2014 2:01:15 AM)

Good one, thanks Per!

Santosh Achanta
( By Santosh Achanta, 2/18/2014 12:01:00 AM)

Good to have a null check before joining otherwise, when you try to publish a page that has meta keywords empty, will throw null reference exception.

( 2/18/2014 8:40:27 AM)

@Santosh: I thought I hade published the code with the null check that I added. Blog post updated.

Gayathri Saravanan
( By Gayathri Saravanan, 3/18/2014 4:00:54 PM)

Good idea...

Please login to comment.