eZ Community » Forums » Developer » Before object create trigger
expandshrink

Before object create trigger

Before object create trigger

Friday 23 September 2011 12:21:05 pm - 6 replies

Is possible create a custom trigger that run workflow before an object is created?

Thank you.

Friday 23 September 2011 3:01:54 pm

Yes, take a look at the admin view "Setup -> Triggers" on admin siteaccess uri '/admin/trigger/list'

Use the trigger "content publish before" and assign it to your custom workflow event.

I've used this feature before several times in custom workflow events.

 

Cheers,

Heath

Modified on Friday 23 September 2011 3:02:53 pm by // Heath

Friday 23 September 2011 3:30:30 pm

Hi Heath,
the before content publish is different from before content created because i need call workflow befare object saved on db.

I think that I need to create a custom trigger, id it right? Can i create a on before create trigger?

Friday 23 September 2011 4:11:44 pm

Hi Domenico,

First, What are you trying to actually accomplish with this custom workflow?

Second, the content/publish/before trigger is run before a content 'node' is created, before this the node does not exist.

So while your right that the content object is created before the node, there is not (to my knowlege) a trigger for content object creation. [0] See: AvailableOperationList

[0] https://github.com/ezsystems/ezpublish/blob/22a6b8592f8f604bb9b5ea9bd60b33ac519f3530/settings/workflow.ini

I think that if you explain more clearly what you need to accomplish we can help you reach your goal.

I do not think kernel hacking eZ Publish content module to add a content/before/create (object) custom trigger is a good solution at all.

 

Cheers,

//kracker

MC Chris : KILL IT

Modified on Friday 23 September 2011 4:12:27 pm by // kracker

Monday 26 September 2011 12:32:07 pm

Hi kraker,
thank you for the answer.

This is my problem.

I have two registration form.

The first ( "customer" ) is standard, no workflow and user will be created in guest user group.

The second ( "artist" ) is very complicated.

It have different registration form and when a user submit the request the administrator must approve registration, and if he do it, the artist must be move from guest user group to the artist user group.

My idea is create a new trigger OnCreatedObject to apply only User object, if User Object have "artist parameter" i move it from guest user grop to artist user group.
Then administrators use the classic trigger "Before Pubblish" to approve it.

Have you another idea? Can you help me?

Thank you.

Domenico. 

Modified on Monday 26 September 2011 12:33:41 pm by Domenico Garozzo

Tuesday 27 September 2011 1:35:26 pm

You should still be able to do this with the regular 'Before publish' trigger.

You could maybe:

  • create a custom 'Content approval' workflow event
  • create a 'Before publishing' workflow
  • assign 'Before publishing' workflow to the 'Before publish' trigger
  • add a workflow multiplexer to execute your custom 'Content approval' workflow event on the publication of a 'User' object.
  • Inside the 'Content approval' workflow event you would:
    • auto-approve 'customer' users
      • the user object would be left in the 'Guest users' group
    • wait for manual approval for 'artists' users
      • at this moment the user object is just a draft, it does exist in the DB but it will not appear in the 'Guest users' group as the object is not yet attached as a node in the content tree.
      • when approved, the 'Content approval' workflow would then move the user object into the 'Artist users' group

Hope this helps

Tuesday 27 September 2011 2:33:11 pm

It's so simple!

I haven't thinked this solution!

Thank you very much!!!

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from