using external ~ action.default.php ~ files

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
mikemcvey
Forum Members
Forum Members
Posts: 61
Joined: Tue May 02, 2006 4:08 am

using external ~ action.default.php ~ files

Post 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 :)
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

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

Post 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
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
mikemcvey
Forum Members
Forum Members
Posts: 61
Joined: Tue May 02, 2006 4:08 am

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

Post 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
Post Reply

Return to “Developers Discussion”