Page 1 of 1

using external ~ action.default.php ~ files

Posted: Sun May 14, 2006 7:45 am
by mikemcvey
Hi,

I have noticed in the News module etc that they use external php files to contain actions... such as action.default.php

I am trying to write my first module and my Module.php file is getting very bloated but for the life of me I can't figure out how to call external files...  It isn't clear in the News Module where this happens... I can't see any includes

Any ideas?

Be great if it was included in the Skeleton Module (which had been the best!)..

thanks,

Mike McVey

been hard work getting my head around modules but am just loving CMSMS :)

Re: using external ~ action.default.php ~ files

Posted: Sun May 14, 2006 1:47 pm
by calguy1000
The action.xxxx.php files are called by default from the base class DoAction.  If you don't override DoAction in your module.php file, then it will expect all actions to be in action.xxxx.php files.

However, if you want some of your actions inside the xxxxxxx.module.php file, and some in action.xxxx.php then you'll have to do something like this:

Code: Select all

function DoAction ($action, $id, $params, $returnid = -1)
  {
    switch ($action)
    {
        case 'action1':
            $this->_DoAction1($action,$id,$params,$returnid);
            break;

        case 'action2':
            $this->_DoAction2($action,$id,$params,$returnid);
            break;
 
      /* note, this is different from case 'default': */
       default:
            /* call the base class' DoAction method for actions we're not handling in this file */
            parent::DoAction( $action, $id, $params, $returnid );
            break;
    }
  }
Hope this helps

Re: using external ~ action.default.php ~ files

Posted: Sun May 14, 2006 9:38 pm
by mikemcvey
Awesome..

thanks so much.. I was getting frsutrated trawling through all my functions in one place.

This really helps me out.  ;D

Mike