Dec 16, 2013

SharePoint 2010 Search show default display form instead of custom display form

I had a problem where SharePoint Foundation 2010 Search was returning the DispForm.aspx in the search results instead of the CustomForm.aspx that was configured as the default display form.

Solutions (I like option 3 best):
  1. Configure the search engine, but with Foundation Search, there's hardly anything to configure.  
  2. Eliminate or hide the DispForm.aspx, but I learned in SharePoint 2007 that doing anything drastic to the default DispForm.aspx can break a list in strange, un-repairable ways.
  3. Use the following JavaScript redirect in a content editor webpart in the DispForm.aspx:
    <script type="text/javascript">
    
    function redirectForm() {
    var pagemode = GetUrlKeyValue('DisplayMode', false);
    
    if(pagemode == null || pagemode == "")
     {
             var hrefCurrent = window.location.href;
             var hrefNew = hrefCurrent.replace("DispForm.aspx","CustomForm.aspx");    
        window.location.href = hrefNew;
     }
    }
    ExecuteOrDelayUntilScriptLoaded(redirectForm, "sp.js");</script>
    

1 comment: