Create global event hendler to add no of child folder when create new product under website

Rahul Raghuvanshi asked on June 25, 2015 16:31

Hello Experts,

I am on beginner level in Kentico, I am developing page application with Kentico CMS version 8.2. I need help to implement following logic: Explanation: I want to add specific no of folders as child page under the new product page type at the time of new product insert. Like:

/ (root)
 - Products (added page type cms.MenuItem)
    - ProductXYZ (added page type cms.product)
        - Folder_A
        - Folder_B
        - Folder_C
        - Folder_D

In above all the child folder under the ProductXYZ need to create automatically just after ProductXYZ insert. I have explored for this and got that need to create global event handler and register it. form this url:

Above link explained how to create global event handler and register it:

private class CustomDocumentEventsAttribute : CMSLoaderAttribute {

    public override void Init()
        // Assigns custom handlers to events
        DocumentEvents.Insert.After += Document_Insert_After;
        DocumentEvents.InsertLink.Before += Document_InsertLink_Before;

    private void Document_Insert_After(object sender, DocumentEventArgs e)
        // Add custom actions here

With this I understood that I need to put code under the method Document_Insert_After, but I am new with Kentico and don't have experience with Kentico API and code.

Please help me what code should I write to get currently created product node and add new child folder under that. Example code will help me a lot.

Thanks in advance.

Recent Answers

Joshua Adams answered on June 25, 2015 16:40

In your project there should be a folder named CMSAPIExamples. This folder should include most of what you need as far as the code/api. The directory /CMSAPIExamples/Code/Documents should contain the items you need to complete this. Maybe try looking at the Basics folder underneath documents and look at the .cs file for default.aspx. That should at least get you started.

0 votesVote for this answer Mark as a Correct answer

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