Page 1 of 1

[SOLVED] CMSMS Development Cookbook Module not working

Posted: Sun Mar 23, 2014 4:12 pm
by chillifish
I've just bought the CMSMS Development cookbook as I need to write a module and there seems to be a paucity of information available online as to how to go about this.

I've tried the very first exercise, writing the following code and saving as HelloWorld.module.php in the HelloWorld directory, but when I go to Extensions > Modules, it seems to cause an error. Am I doing something wrong, or, is the Development Cookbook too old and have I made a mistake buying it?

Code: Select all

<?php
class HelloWorld extends CMSModule {

	functionGetName() {
		return 'HelloWorld';
	}
	
	functionIsPluginModule() {
		return true;
	}
	
	functionDoAction($action, $id, $params, $returnid=-1) {
		echo 'Hello World. Welcome to the '.$this->GetName().' module (version '.$this->GetVersion();
		echo ') running in CMS Made Simple version '.CMS_VERSION;
	}
}
?>

Re: CMSMS Development Cookbook Module not working

Posted: Sun Mar 23, 2014 4:20 pm
by chandra
You have to set a space after function ;).

And function GetVersion() is not defined in your example.

Re: CMSMS Development Cookbook Module not working

Posted: Sun Mar 23, 2014 4:28 pm
by chillifish
Thanks for that, I had wondered about that, but it doesn't have a space in the book, so I thought maybe they were existing functions all labelled with function in front of them! Pretty basic error for the first chapter of the book, I hope the rest of it's a bit better!

Re: [SOLVED] CMSMS Development Cookbook Module not working

Posted: Sun Mar 23, 2014 5:31 pm
by chandra
Make a look too to News module - it's something like a reference module.

So it's possible to define the functions as public, private and so on.

Re: [SOLVED] CMSMS Development Cookbook Module not working

Posted: Sun Mar 30, 2014 6:10 pm
by Dr.CSS
At this point that book may be considered quite old/out of date as the API may have changed quite a bit since it was published...