ploneplone-5.x

Plone automatic content generation following folder generation


I was asked to implement the following on my Plone installation:

After a user created a new folder, he should be forwarded to the creation of a new page which should then be the default view of the folder.

I tried to achieve that using content rules, but unfortunately such behavior is not supported there.

What is your suggestion of achieving that behavior?


Solution

  • The following should be a solution for your Problem

    Define an Eventhandler in events.py

    def notifyFolderIsAdded(folder, event):
        folder.REQUEST.RESPONSE.redirect(folder.absolute_url() + "/++add++Document")
    

    Register the EventHandler in configure.zcml

    <subscriber
       for="plone.app.contenttypes.interfaces.IFolder
            zope.lifecycleevent.interfaces.IObjectAddedEvent"
       handler=".events.notifyFolderIsAdded" />
    

    Look at Events and Event Handlers in Plone Docs.