SharePoint 2013 Customize Search results to redirect to a custom URL instead of opening a word or dispform.aspx of an item

Rajiv, Shanmuga Priya 41 Reputation points
2020-12-01T13:09:33.347+00:00

Hi

I have a document library with documents for which a custom view page (in site pages) is created and it is used in the application level.

Would like to check if the search results of the document library can redirect users to that custom url with ID as querystring.

Also we have another similar requirement to redirect search results to a site page with ID as querystring for a SharePoint list instead of DispForm.aspx

SharePoint Server
SharePoint Server
A family of Microsoft on-premises document management and storage systems.
2,227 questions
0 comments No comments
{count} votes

Accepted answer
  1. Amos Wu-MSFT 4,051 Reputation points
    2020-12-02T07:18:06.897+00:00

    You need to customize SharePoint search display template. And you could get the item URL with ctx.CurrentItem.Path, then you could get the ID value and append it to the view page url.

    SharePoint 2013 Customize Display Template for Content By Search Web Part (CSWP)
    Understanding how classic search results are displayed in SharePoint Server
    My simple test :

    <a href=" http://sp/SitePages/WikiWiki.aspx?_#= ctx.CurrentItem.Path.split('?')[1] =#_">http://sp/SitePages/WikiWiki.aspx?_#= ctx.CurrentItem.Path.split('?')[1] =#_</a>  
    

    Test result:
    44323-image.png


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful