exchanging DoAction with method.something.php

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
epic
New Member
New Member
Posts: 2
Joined: Fri Jan 06, 2012 9:42 pm

exchanging DoAction with method.something.php

Post by epic »

Howdy,

I am a CMSMS noob, but veteran programmer. I've created my own module. It works fine when I have a DoAction method. However, I can't seem to get it to work by moving the method to method.sayhowdy.php.

Sorry if this question has been asked before, but I have searched the forum/google to no avail. I'm sure I'm doing a very basic thing wrong. I've reduced the problem to the most basic code below.

I have CMSMS 1.10.2 running on Fedora 12, Apache 2, MySQL 5.1.42, PHP 5.3.3.

Below is my situation. Thanks.


SOURCE CODE:

$ ls /home/html/cmsmadesimple/modules/howdy | more

drwxrwxr-x 2 dan web 4096 2012-01-06 15:49 .
drwxr-xr-x 13 nobody web 4096 2012-01-06 15:21 ..
-rwxrw-r-- 1 dan web 879 2012-01-06 15:37 howdy.module.php
-rwxrw-r-- 1 dan web 6 2012-01-06 15:22 method.install.php
-rwxrw-r-- 1 dan web 80 2012-01-06 15:30 method.sayhowdy.php
-rwxrw-r-- 1 dan web 6 2012-01-06 15:22 method.uninstall.php

$ cat howdy.module.php
<?php
if( !isset($gCms) ) exit;

class howdy extends CMSModule
{
function SetParameters()
{
$this->RegisterModulePlugin();// allows us to use {howdy} instead of {cms_module module='howdy'}
}
function GetName()// must return the exact class name of the module
{
return 'howdy';
}
function GetFriendlyName()// name shown in Admin Menus
{
return 'howdy';
}
function GetVersion()// CMS will use this to identify whether installed version is current
{
return '0.1';
}
function IsPluginModule()// return true so this module can be included in template/page
{
return true;
}
function InstallPostMessage()
{
return 'howdy has been installed';
}
function UninstallPreMessage()
{
return 'uninstall howdy?';
}
function UninstallPostMessage()
{
return 'howdy uninstalled';
}
function DoAction($action, $id, $params, $returnid=-1)
{
if ($action == 'default') {
echo 'howdy';
}
}
}
?>

$ cat method.install.php
<?
?>

$ cat method.sayhowdy.php
<?
error_log('method.sayhowdy.php');
if( !isset($gCms) ) exit;
echo 'howdy';
?>

$ cat method.uninstall.php
<?
?>


*** TEST 1 ***

CONTENT > PAGES > ADD:

<p>[{howdy}]</p>


OUTPUT:

...
<p>[howdy]</p>
...


*** TEST 2 ***

$ cat howdy.module.php
<?php
if( !isset($gCms) ) exit;

class howdy extends CMSModule
{
function SetParameters()
{
$this->RegisterModulePlugin();// allows us to use {howdy} instead of {cms_module module='howdy'}
}
function GetName()// must return the exact class name of the module
{
return 'howdy';
}
function GetFriendlyName()// name shown in Admin Menus
{
return 'howdy';
}
function GetVersion()// CMS will use this to identify whether installed version is current
{
return '0.1';
}
function IsPluginModule()// return true so this module can be included in template/page
{
return true;
}
function InstallPostMessage()
{
return 'howdy has been installed';
}
function UninstallPreMessage()
{
return 'uninstall howdy?';
}
function UninstallPostMessage()
{
return 'howdy uninstalled';
}
/* function DoAction($action, $id, $params, $returnid=-1) REMOVED! */
}
?>

$ cat method.sayhowdy.php
<?
error_log('method.sayhowdy.php');
if( !isset($gCms) ) exit;
echo 'howdy';
?>


CONTENT > PAGES > CHANGE:

<p>[{howdy action='sayhowdy'}]</p>


OUTPUT:

...
<p>[]</p>
...

* In addition, error_log('method.sayhowdy.php'); does not get called.
epic
New Member
New Member
Posts: 2
Joined: Fri Jan 06, 2012 9:42 pm

Re: exchanging DoAction with method.something.php

Post by epic »

Please forgive me. I named the files method.* instead of action.*.
D'oh!
Figured it out by examining lib/classes/class.CMSModule.php.
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: exchanging DoAction with method.something.php

Post by Wishbone »

This same question was the topic of my first post as well.

http://forum.cmsmadesimple.org/viewtopi ... 28#p139128

Should be named action.sayhowdy.php

I used to use CGBlog as my example to figure how things work.
Post Reply

Return to “Developers Discussion”