Quote from: BobRay at Aug 29, 2009, 03:03 PM
I’m wondering about the example code in the two examples here: http://svn.modxcms.com/docs/display/revolution/Plugins
In the first example, isn’t unnecessary (and potentially confusing)?
Should it maybe be return; or return ’’; ?
You are correct, you don’t need to return anything, though a blank string is fine.
Quote from: BobRay at Aug 29, 2009, 03:03 PM
Shouldn’t line 5 in the second example be:
if (!empty($errorPage)) { ??
I don’t think so; it’s saying if no $errorPage is defined or it has an empty value to show the MODx error page, otherwise send an email and redirect to the defined page.
I would also suggest the following changes to start with...
* If the plugin is only intended to operate on a single event, there is no reason for the switch statement at all. This is unnecessary overhead.
* Creating a reference to $e = &$modx->Event is unnecessary and the uppercase $modx->Event is deprecated. It should be $modx->event and the switch statement, if necessary in more complex plugins intended to be registered on multiple events, could simply be
switch ($modx->event->name) {
Then I’ll work on some additions to this, like a new example plugin that is intended to be registered on multiple events, as well as an example to demonstrate using return values, generating output, stopping propagation of the event to additional registered plugins, etc.