API to add File Type pages in Content Tree ?

Ravichandran R asked on July 22, 2016 10:33

Is there any api to Insert a file Type page in the Content Tree?

Recent Answers


Trevor Fayas answered on July 22, 2016 15:08

Here's the API for for a general insert (you would use this to create the File cms object)

https://docs.kentico.com/display/API9/Pages#Pages-Pagecreation

Then add to it the API for attaching files to a page (which you would then set as the field for the File portion of the File pagetype object)

https://docs.kentico.com/display/API9/Attachments#Attachments-Insertingattachmentsintopagefields

0 votesVote for this answer Mark as a Correct answer

Chong FS answered on March 3, 2017 04:55 (last edited on March 3, 2017 04:56)

For the above steps mentioned by Trevor, it is first create a (page)page type file then attaching file with the help of API in the link below, but is there any API can directly create a (file) pagetype directly? Just started to use Kentico,please correct me if i mistaken any explaination

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on March 3, 2017 06:00

Chong, i do not believe so, the reason is that the "File" type in the CMS is actually just a special Page Type + Page Attachment, and in the database you need the page first created so when it creates an attachment it has something to attach it to.

You have the option of instead using the Media Library and having a file there, there are pros and cons to having a file in the Content Tree vs. in the media library, and one may be better for your applications than the other.

Files in the Media Library are just that, actual physical files on your server with a basic database entry that holds some meta data. Easy to place.

Files on the content tree take extra steps but allow you to have different culture variations, security, and can be indexed in smart search.

0 votesVote for this answer Mark as a Correct answer

Chong FS answered on March 3, 2017 06:57

Trevor, thanks for your kind reply, now i understand (file) page type is a special page with page attachment, is that so? Then i can follow the steps to create it by using api,then add attachment to it by using api too. but it will not appear in the tree and smart search cannot index it.

Yes, that is the main reason im considering files on content tree because i need the files to be index by smart search. Is there any recommendation from you?

0 votesVote for this answer Mark as a Correct answer

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