[SOLVED] CMSMS Development Cookbook Module not working

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
Locked
chillifish
Forum Members
Forum Members
Posts: 92
Joined: Wed Jul 27, 2011 9:26 am

[SOLVED] CMSMS Development Cookbook Module not working

Post 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;
	}
}
?>
Last edited by chillifish on Sun Mar 23, 2014 4:32 pm, edited 1 time in total.
chandra

Re: CMSMS Development Cookbook Module not working

Post by chandra »

You have to set a space after function ;).

And function GetVersion() is not defined in your example.
chillifish
Forum Members
Forum Members
Posts: 92
Joined: Wed Jul 27, 2011 9:26 am

Re: CMSMS Development Cookbook Module not working

Post 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!
chandra

Re: [SOLVED] CMSMS Development Cookbook Module not working

Post 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.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12709
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: [SOLVED] CMSMS Development Cookbook Module not working

Post 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...
Locked

Return to “Developers Discussion”