open upload file from custom page type in smart search results

Robert Srigley asked on February 22, 2019 16:31

Further to this question that I posed and was answered by Brenden Kehren (thank you Brenden).

https://devnet.kentico.com/questions/modify-cms-root-smartsearchresults-transformation-to-handle-structured-pages-in-results

My Smart Search Results are returning content from a Custom Page Type. The Custom Page Type contains a File field where I upload a .pdf file.

In the search results, I need to create a hyperlink to open the .pdf file.

The code below is returning the GUID vlaue of the file ( I think ).

<%-- Search result content --%>

<a style="font-weight: 700;" href='<%# SearchResultUrl() %>'> <%#SearchHighlight(HTMLHelper.HTMLEncode(TextHelper.LimitLength(HttpUtility.HtmlDecode(HTMLHelper.StripTags(CMS.Base.Web.UI.ControlsHelper.RemoveDynamicControls(GetSearchedContent(DataHelper.GetNotEmpty(Eval("Content"), ""))), false, true, " ", "@", "")), 280, "...")), "<span style='background-color: #FEFF8F'>", "")%>
  

The GUID resembles this; c32cec60-5072-4952-9532-c6ded448434c

The actual web page that contains this custom page type listing creates hyperlinks which open up as follows; http://staging.informed.tbrhsc.net/getattachment/c32cec60-5072-4952-9532-c6ded448434c/QBP-Acute-Exacerbation-of-Chronic-Obstructive-Pulm.aspx

How do I modify the Smart Search Results to use that GUID to open the correct file?

Thank you for your assistance.

Recent Answers


Robert Srigley answered on February 25, 2019 15:39

vasu yerramsetti, thank you for your response.

The documentation you provided is for version 8. We are running version 11 which does not have Attachment Search types per say.

I created a General Search Type and upon testing, it is returning my .pdf .docx and .xslx files.

The SmartSearchDialogResults wp is returning the document guid.

I still can not figure out how to transform the result into a hyper link that opens the appropriate document in a new window/browser tab.

I have been trying; GetAttachmentUrl GetAttachmentUrlByDocumentId GetAttachmentUrlByGUID

and I have not found the right syntax to open the attachment file.

Any thoughts?

0 votesVote for this answer Mark as a Correct answer

Robert Srigley answered on February 25, 2019 16:03

Sorry, I misred some of the documentation.

My Pages search type was configured to index attachments. So I am still left wondering what the correct syntax is to display the file.

My Custom Page type called tb-Policy-and-Procedure has the Search Fields configured as follows; Title field = PolicyTitle Content field = PolicyFile ** this is what i need to open up. Image field = none Date field = DocumentCreatedWhen

Thank you.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.