This post originated from an RSS feed registered with PHP Buzz
by Forum One.
Original Post: Events, Views, and Auto-generators
Feed Title: Syntax Framework
Feed URL: http://blog.syntaxcms.org/rss.php?version=0.91
Feed Description: Finally, a place to answer Syntax questions
If you need to calculate the properties of an object when its created or edited by users, you have two choices with SyntaxCMS. One option is to use the relatively newer Event Dispatcher. You'll have to create a custom event that listens for a create or update event for the content types that you're interested in that will calculate the new properties. This is probably the most powerful way, and as I found out, you're guaranteed that the Event Dispatcher will notify your events whenever a create or update event occurs.
The other option is to define fields within your content-type as "autogen" plugins. These plugin types have been in SyntaxCMS since the beginning and are a rudimentary and straightforward event to calculate the value of one property based on other object properties. One limitation of this method is that, if you use a content-type view to limit the properties a user can edit, if you ommit your autogen properties from the view, they will not be calculated. Since they are not in the view, when pxdb_commit goes to save the object to the database, it doesn't know about those properties. Since event notification hooks are not tied to the fields being edited by a user, a custom event would still be notified to calculate those properties.
I hope the description above is not too wordy and if it is I'd be glad to help anyone sort it out inthe comments to this post.