[opencms-dev] news module / module creation documentation
david.seikel at icemedia.com.au
Wed Jun 18 01:56:00 CEST 2003
Alexander Langer wrote:
> But now I am running out of gas, concerning writing my first own
> backoffice module. I just don't know where to start with content
> definition and stuff. There is nothing in the documentation that seems
> to be able to help me out.
> I googled the web up and down and couldn't find anything to take as a
> starting point. I just saw a news module circulating in these list,
> but it seems to work with it's own database structure. I want to do it
> the opencms style of way and do it via content definition.
A content definition (CD) is basically a wrapper around data, but there
is no support for storing abitrary data anywhere.
Start by writing Javabean style getX() and setX() methods for your data.
Include checkX() methods for the data as well. Then you need to supply
a few methods that are declared as abstract in A_CmsContentDefinition.
delete() - deletes the data represented by this CD
write() - write the data represented by this CD
getUniqueId() - should return a URL of some sort, dunno much, not used
here. I actually return the unique ID as used by the constructor.
Finally, write three constructors.
MyCD(CmsObject cms) - create empty CD
MyCD(CmsObject cms, String ID) - read CD with this unique ID
MyCD(String name) - may not be needed, dunno, not used here.
You are on your own about how to read / write / delete your data, CDs
hide those details from the openCMS system.
For backoffice support, there are many methods you can override. While
I have not done an actual backoffice module, I have needed to support
similar functionality. These are the most important ones to start with.
getFieldNames() - return a Vector of the names of your data fields.
getFiedlMethods() - return a Vector of your getX() methods.
All else is optional, and can be added slowly as you understand or
require more. Note, there is no method for getting a Vector of the
setX() methods, for my purposes I added one, but BackOffice won't know
to use it. I found it much more useful to write methods that return
Hashtables of the setX() and getX() methods so that my code can deal
with CDs more genericaly.
More information about the opencms-dev