Adding new page

MD Faci Siddiqui asked on December 1, 2020 12:24

I am using kentico 12 MVC website. I want to add a new page to a site using API, the page type is configured as standard content-only.

I am referring Pages API. The example uses these lines add a new page,

// Creates a new page of the "CMS.MenuItem" page type
TreeNode newPage = TreeNode.New(SystemDocumentTypes.MenuItem, tree);

SystemDocumentTypes.MenuItem is classname in application.class format.

What will be the classname in application.class format for page I want to add?

Correct Answer

Juraj Ondrus answered on December 2, 2020 08:19

The TreeNode.New method expects the first parameter to be string. So, you need to either provide some string variable or provide the class name in string format: TreeNode.New("className", tree). Co, it could be like: TreeNode.New("Contact.Email", tree)

0 votesVote for this answer Unmark Correct answer

Recent Answers


Juraj Ondrus answered on December 1, 2020 15:18

The API example uses the "CMS.MenuItem" page type from the portal engine where this page type was marked as s system page type (like root, file, etc.). In your code you need to replace this part with the actual code name of your page type. Sample screen shot where to get the code name. So, for example in this case the code name would be: DancingGoatMvc.Article

0 votesVote for this answer Mark as a Correct answer

MD Faci Siddiqui answered on December 1, 2020 16:13

@Juraj Ondrus I tried using the code name. I am getting reference error.

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on December 2, 2020 05:21

What is the exact error and its details and what is your code like?

0 votesVote for this answer Mark as a Correct answer

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