A reader asks:
I’ve been given a custom web part based on the SharePoint 2010 Core Results Web Part. The web part overrides OnInit to provide a custom search query to the web part. I need to modify it to add a button in a new column. How can I do that in a way that adapts to the proper document content type?
Personally, I’ve used the Core Results Web Part to aggregate Document Results before, but I don’t remember needing to resort to custom code. Generally, if something can reasonably be done by configuration, I always recommend that over custom code. In this case, I’d suggest re-factoring the solution to determine if the custom web part can be removed. The core results web part is meant to be extensible through modifications to it’s web part properties, the managed search properties and XSLT.
Having said that, neither modifying the existing custom code nor configuring the core results web part are simple enough that I would try to explain in a short time. There’s a lot to consider and for the first time developer of this type of change, a bit of reading I’d recommend before starting.
First, my suggestion is to review the Microsoft documentation on the Core Results Web Part. TechNet Article Change how search results appear in the Search Core Results Web Part (Search Server 2010) provides a good introduction to the web part and what the best options are for changing it.
After exhausting Microsoft’s official documentation and any SharePoint books I have handy, I wouldn’t hesitate to recommend reading the blogs of two fellow Texan SharePoint MVPs. In this case, the MVP blogs go much deeper than anything on Microsoft.com and there are some very high quality posts on the subject by experienced SharePoint developers.
Corey writes quite a lot about SharePoint Search in general. Just check out the Enterprise Search tag set on his blog. In particular, I might start with two posts specific to the Core Results Web Part:
- Using search to find recently modified files in SharePoint 2010
- A quick guide to CoreResultsWebPart configuration changes in SharePoint 2010
Between Matthew and Corey, South Texas is well covered in SharePoint Search developers. On Matthew’s blog, I’d start with a search on Core Results which currently shows more than 10 posts on the subject. In particular, I recommend two articles, the first showing a very helpful troubleshooting step and the second showing a unique customization related to the reader’s question.
SharePoint Development presents many unique challenges and requires a good understanding of the platform to develop solutions that are efficient and maintainable. I recommend reading about the problem area before starting a new SharePoint Development project. There is so much to learn.
The Core Search Results Web Part is very powerful. Building a solution around it justifies some investment of time learning before coding. While it is always possible to write your own custom code that does something that SharePoint already does, the trade off is too much for me in most cases. Instead, I recommend configuration, which arguably is still complex web development in this case, because it probably requires XSLT to be written and content type and search property GUID’s to be identified.
Microsoft provides a wealth of articles on MSDN and TechNet which are a primary reference. There are many SharePoint Development Books available, some are even search specific. On top of those resources, the SharePoint Community provides quality content that can’t be overlooked.