Each content type is defined by an XML file uploaded to the system. This is nothing new - numerous systems work this way - but the key benefit to working with types in Moski2.net is that you don't have to build the administrative interface for the type. No tedious building of HTML forms and logic, and no scaffolding to auto-create code to manage the type either - once you've created the XML, you've created both the type definition and the interface.
Beyond a little meta data about the type, the type definition is all about describing the fields that make up the type, and how they should behave in the administrative interface. Before walking through all the field types and how to put together a content type, here's a quick example of what a simple news type could look like:
<?xml version="1.0" encoding="UTF-8"?> <contentType id="news"> <title lang="en" number="single">News</title> <title lang="en" number="plural">News</title> <title lang="da" number="single">Nyhed</title> <title lang="da" number="plural">Nyheder</title> <sorting direction="desc" fieldName="published" type="field" /> <fields> <field id="heading" linkField="1" multiLingual="1" type="text"> <title lang="da">Overskrift</title> <title lang="en">Heading</title> <rules> <required /> </rules> </field> <field id="published" multiLingual="0" type="date"> <title lang="da">Dato</title> <title lang="en">Date</title> </field> <field id="illustration" multiLingual="0" type="image"> <title lang="da">Billede</title> <title lang="en">Picture</title> </field> <field id="body" multiLingual="1" type="htmlarea"> <title lang="da">Brødtekst</title> <title lang="en">Body</title> <rules> <required /> </rules> </field> </fields> </contentType>
Presumably this won't throw you off and you probably get the basic idea - some title and sorting information, and a list of field definitions. Once this XML is uploaded to the system you can immediately:
Enter records of this type in the administration
Grant access to this content type to users
Link to this type in other type definitions
Retrieve content of this type with an M2_Content::get()
call
Save content of this type from a public site using M2_Content::put()
Cross link this type into user profiles
The following sections walk you through all the field types and rules available to build your own types.