Kentico CMS 6.0 Developer's Guide



Previous topic Next topic Mail us feedback on this topic!  


Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

Document Attachments are a concept of attaching files to documents in Kentico CMS. This concept greatly simplifies the way you work with files. Each document can have any number of attached files, which is a great step forward compared to the previous use of the File field, which allowed only one uploaded file per one defined File field.


Attachments are directly bound to a document's life cycle. So if a document gets published, its attachments get published too. If you delete a document, its attachments will also be deleted.


There are two types of attachments:


Unsorted - added via the Properties -> Attachments tab; using this approach, you can easily add attachments to any document; all attachments added this way are taken as one group and displayed together using the web parts

Grouped - added by defining a 'Document attachments' field for a document type and then uploading a file on a document's Form tab; for each Document attachments field, you can have an unlimited number of files attached; you can also define more fields of this type to have several groups of attachments which can be displayed separately on the live site

File field - another type of field that can be used for file upload via the Form tab; the difference from Grouped attachments is that only one file can be uploaded into one File field


The attachments can be displayed with the document using one of the following web parts:


Attachment image gallery - using the default transformation, the web part displays thumbnails of the document's image attachments. After a thumbnail is clicked, a lightbox will display the attachment in full size. For non-image attachments, a file type icon will be displayed instead. If clicked, the file will be offered for download. Of course, this behaviour can be modified by defining a custom transformation.

Document attachments - displays a list of document's attachments. After an attachment is clicked, it is opened in a new window or offered for download in case that it is not an image.

Attachments data source - data source web part for providing attachments to a connected displaying web part; see also Using Data source web parts.


More information about the web parts can be found in the Available web parts topic.


You can also display a document's unsorted attachments using the following two inline widgets that can be added via the Editable text web part:


Attachment image gallery - displays thumbnails of the document's unsorted attachments in a gallery. After a thumbnail is clicked, the attachment will be displayed in a lightbox.

Document attachments - displays the document's unsorted attachments. After an attachment is clicked, it will be displayed on a new page if it is an image and non-image attachments will be offered for download.


More information about the inline widgets can be found in the Available inline widgets topic.


Settings which can be configured in Site Manager -> Settings -> System -> Files are applied to document attachments. You can learn about available settings in the Files-related settings chapter.