Attaching files to a page

Sara Fludd asked on December 17, 2018 14:45

Good morning! Attaching files to pages has me stumped. I've attached files as explained here: https://docs.kentico.com/k9/managing-website-content/working-with-files/page-attachments/attaching-files-to-pages

Added the web part to display on my template - but the default macro gives a 404 error for each file link.

The file url is something like this: https://the.url.net/cms/getattachment/474219f2-e3a1-4d74-995a-1540a190a04d/11-the-document.pdf;.aspx

But the default transformation

<div>

<a target="_blank" href="<%# GetAbsoluteUrl(GetAttachmentUrl(Eval("AttachmentName"), Eval("NodeAliasPath")), EvalInteger("AttachmentSiteID")) %>"> <%# Eval("AttachmentName",true) %>

gives me something like this:

https://the.url.net/cms/getattachment/page-name/11-the-document.pdf;.aspx

I'm not grouping these files - my goal is to attach up to 50 files to a page - then use Smart Search to be able to filter them by searching any term on the uploaded documents. "The smart search allows users to search through the content of files uploaded as page attachments. The attachment search supports both types of file storage provided by Kentico (database or file system)." (lets hope this works)

I've looked at Brandon's blog post - but these are ungrouped attachments - so I'm still unable to find a solution. thanks in advance for your feedback.

Correct Answer

Juraj Ondrus answered on December 17, 2018 15:49

Hi,
When you look at the link's extension https://the.url.net/cms/getattachment/page-name/11-the-document.pdf;.aspx - it is an invalid extension. I guess if you remove the extension or leave just .aspx, the attachment will be displayed. I assume you have followed the extensionless URLs documenation and you have set the multiple extensions in the Files friendly URL extension setting (sample screen shot) - it says extension and not extenstions. So only one extension is allowed. I would recommend leaving this setting empty to allow any file extension.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Peter Mogilnitski answered on December 17, 2018 15:52

the transformation seems correct, what seems weird is that you have semicolon at the end: 11-the-document.pdf;

0 votesVote for this answer Mark as a Correct answer

Eric Dugre answered on December 27, 2018 18:32

Sara, please let us know if Juraj's answer helped you, or if you still need more assistance. If so, please let us know how you have the URLs and SEO settings configured.

0 votesVote for this answer Mark as a Correct answer

Sara Fludd answered on December 27, 2018 19:23

Hi Eric and Juraj,

I had not gone back to this due to the holidays - but what I have for Files friendly URL extension is: ;.aspx

Not sure why it was set up that way - should I remove the semi-colon?

Thanks, Sara

0 votesVote for this answer Mark as a Correct answer

Sara Fludd answered on December 27, 2018 19:37

Yup - removing the semi-colon did the trick. Many thanks!

0 votesVote for this answer Mark as a Correct answer

Sara Fludd answered on January 15, 2019 15:39

Still working through this - the page attachments now show correctly - and I've added the smart search dialogue and the requisite search index. But when I search for any of the terms on the documents the search result returns the page the document is on - not the specific attachment where the term lies. Where am I going wrong?

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on January 24, 2019 11:26

What is the attachment like - is it PDF or Word or text file? How is the searching in attachments configured?

0 votesVote for this answer Mark as a Correct answer

Sara Fludd answered on January 24, 2019 12:39

They are pdfs configured thusly: Attachments uploaded in the Pages application on the Properties -> Attachments tab of pages

0 votesVote for this answer Mark as a Correct answer

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