Page 1 of 1

How to create of a module for a new content type

Posted: Mon Nov 03, 2008 11:29 pm
by robbedoes
I'm designing an app to create a kind of SWF ads.
I want to make use of AMFPHP for the front end and CMSMS for the back end.
The ads will be displayed on the frontpage using a tag which requests an amf service.
The service will be handled by a custom cmsms module.

I've got one question about this:

How do I create a content type module?
The http://wiki.cmsmadesimple.org/index.php/User_Handbook/Developers_Guide/Module_Tutorial does mention this kind of module but there are no details...

Maybe someone out there can give me some info.

Thanks,

Rob

Re: How to create of a module for a new content type

Posted: Tue Nov 04, 2008 3:51 am
by NaN
Create a Module as described in the doc (or download skeleton module or modulemaker).
At first you need to "register" your contenttype to the CMSms core.
This is done in the [ModuleName].module.php.
There is a funtion called SetParameters:

Code: Select all


function SetParameters()
{
	$this->mCachable = true;
	$this->RegisterContentType('NameOfYourContentType', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'contenttype.[NameOfYourConentType].php', $this->GetFriendlyName());
}


Then create a file called contenttype.[NameOfYourContentType].php.
The File starts with a class declaration:

Code: Select all


class NameOfYourContentType extends CMSModuleContentType
{
     ...
}


Take a look into the file lib/classes/contenttypes/Content.inc.php to figure out how to create a contenttype file.
If you don't need the module but just the contenttype you also can just copy and modify that file.

After that your contenttype can be selected when adding or editing a page.

Hope that helps.

Re: How to create of a module for a new content type

Posted: Tue Nov 04, 2008 3:09 pm
by robbedoes
Hi NaN,

Thank you, I'll give it a try this week. Hope I get it working.

Cheers,

Rob