Reputation: 4724
I have a problem that I need to attach files to a document that are in the media library.
Out of the box Kentico only seems to allow direct upload on the attachments section and on the related document you can only relate other content/documents on the site.
I want to be able to attach a file as a related document or attachment from a media library.
I looked online for this but I cant find anything.
My plan at the moment is to add a custom section to "Add related media files" but if there is a easier way it would be great.
To clarify I need to be able to add multiple media files to a document.
Regards
Upvotes: 2
Views: 979
Reputation: 7696
Attachments and Media files are two different things (they are meant for different purposes). If you don't want to duplicate the content customize your document type (add a field of Media selection type to it). Unfortunatelly this allows to add only one item per field.
You can also use object relationship API - ObjectRelationshipInfo & ObjectRelationshipInfoProvider. You should be able to get media file using
BaseAbstractInfoProvider.GetInfoById("media.file", MediaFileID)
and document using
BaseAbstractInfoProvider.GetInfoById("cms.node", NodeID).
There is also simple UI located at CMSModules/AdminControls/Pages/ObjectRelationships.aspx - but please be aware these things are not officially supported yet.
If you don't want to add multiple fields to your document type you will probably have to use the API and create relationships between documents and media files (as described above). The drawback of this solution is that you will probably have to create UI that will suit your needs and probably create some webparts (or customize existing) that will take the relationships into account.
Upvotes: 1
Reputation: 56
The Attachments section under the Properties tab is just for physical files and as you mentioned it requires upload them from your file system. If you need to link a media from the media library to your document, there are other ways how to do that. You can just add the Media selection field to your document type to be able to select media files under the Form tab instead.
Upvotes: 2
Reputation: 159
Is it a requirement that the files have to created as an attachment?
If it's not, I would consider adding a media selector field to that document type to link an existing media library file.
Upvotes: 1