Creating a Poll Content Type

To create a poll content type, you must edit your publication's content-type resource, which is located in the publication's META-INF/escenic/publication-resources folder. The following example shows a simple poll content type similar to the one used in the poll-demo publication. It defines a field group containing a title field, a question field and three alternative answer fields. It then defines a content type which places this group of fields in the default panel.

<field-group name="poll">
  <field mime-type="text/plain" type="basic" name="title">
    <ui:label>Title</ui:label>
  </field>
  <field mime-type="text/plain" type="basic" name="question">
    <ui:label>Question</ui:label>
  </field>
  <field mime-type="text/plain" type="basic" name="svar1">
    <ui:label>Alternative 1</ui:label>
  </field>
  <field mime-type="text/plain" type="basic" name="svar2">
    <ui:label>Alternative 2</ui:label>
  </field>
  <field mime-type="text/plain" type="basic" name="svar3">
    <ui:label>Alternative 3</ui:label>
  </field>
</field-group>

<content-type name="poll">
  <panel name="default">
    <ref-field-group name="poll"/>
  </panel>
</content-type>

The result of adding this code to the content-type resource will be that a new content type will be added to the publication and made available to Content Studio users. Note the following:

  • The above code is an example and deliberately kept short. A real polling content type would be likely to have a much larger number of alternative fields, in order to give Content Studio users the possibility of creating polls with many alternatives when necessary.

  • You can give the field containing the poll question any name you like.

  • The alternative fields, on the other hand, must (at least by default) have names starting with the prefix svar. You can change this prefix to something else by editing the configuration file MentometerManager.properties. For further information about this, see Set MentometerManager Properties.

The above content type definition will produce content items that looks like this in Content Studio:

graphics/poll-content-item.png