4. Defining Content Types

4.1. Field Types
4.1.1. date
4.1.2. file
4.1.3. filemanager
4.1.4. image
4.1.5. link
4.2. Common Field Attributes
4.3. Field Rules
4.4. Content Callback
4.5. Controlling Content Indexing
4.6. Controlling Behavior
4.6.1. Sorting
4.6.2. Presentation in the administration
4.7. Common Issues
4.7.1. Illegal field ID attribute values
4.7.2. Sacred variable names

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:

The following sections walk you through all the field types and rules available to build your own types.