|Number of votes:||1|
As many of you might now I left EPiServer two weeks ago for a new adventure at Logica… But before I left I was working a lot with a project about migration from Relate+ to Relate+ 2.0, http://world.episerver.com/Articles/Items/Migrate-EPiServer-Relate-1-to-EPiServer-Relate-2/.
If you start a new project you will soon find out that there are no search for ordinary cms content. Even though Relate+ 2.0 have search for all community content, and cms-pages as well.
So on EPiCenter, EPiServer’s own intranet, they had a lot of pages that needed to be found. So what I needed to do was to extend the existing functionality with a little bit more code.
So we add a new usercontrol in the SearchControls folder:
My code ended up like this:
We also need to create some logic:
The important part of this code is the method protected override string GetDesc(object dataItem), this will get some of the text indexed on the specific page in the property mainbody. You could make some changes so that it will take all text that is index on the specific page by changing this:
To instead use responseItem.DisplayText().
This will result in that all text will be included from other properties on the specific page as well.
First I add a new menuitem to search.aspx
We now need to create a property called PageResultPageLink in code behind:
Now I need to get the result for pages and to do that we need to do some changes in SearchResult.aspx. Ee need to create a new method called LoadPageResult() and use that in the Onload method on SearchResult.aspx.
The LoadPageResult()-method should now use our usercontrol that we created earlier, something like this:
and the changes to OnLoad should end up something like this:
Finally we need to add the LoadPageResult() to LoadAllKindOfElementResult(), method for rendering all searchcategories, as well. Otherwise pages will not show unless the visitor clicks on the menu item for showing pages. This method can be found in SearchResult.aspx.cs.
Well I think thats about it and now we have extended the Relate+ 2.0 templates so that it uses the index for ordinary cmspages as well
If you are experience any problems getting the indexed results, you will need to check the adress of the indexingservice. I made changes to the default installation so that the site could be found on localhost:17000 and therfore I had to change the indexingservice as well to use the same adress, otherwise it uses the computername instead of localhost by default.
You can also download the migration tool, and use the reindex tool included in that package to get a new index.