Poll Plugin Developer Guide - Poll Documents
Creating Poll Document Types
The Poll plugin provides a Poll document type out of the box. It is a simple wrapper around the poll compound, which defines the core data of the poll document.
You can create your own poll document type(s) in the Configuration section of the Content application. Your document type must include the poll compound provided by the poll plugin at the document's top level, and may contain any other fields you desire. When working with your own poll document type, you will have to provide a content bean representing your document type. Also see the poll-docsClass and poll-pollCompoundName parameters of the poll component. When working with a poll component which supports the explicit selection of a poll document for rendering on your site (default, recommended), you also need to create your own specialization of the PollComponent, much like the PollDcumentComponent does, limiting the document picker to your specific poll document type (see the @JcrPath annotation in the PollDocumentComponentInfo).
The default poll document type comes with a poll results plugin that shows the number of votes on the various poll values. If you want it in your own poll document type as well, copy its configuration from /hippo:namespaces/poll/polldocument/editor:templates/_default_/poll-result into your own type.
Creating Poll Documents
A poll document is a document with a 'multiple' field to hold all the available options a poll has (the possible answers). To create a new poll, navigate to the Documents section of the Content application. We'll create a new Poll document in there. From the context menu of a folder which allows the creation of poll documents, select Add new document. Provide a name, optionally a URL name, and in the Document type dropdown select Poll. Click OK and the document editor opens to edit the new Poll document.
Now you should fill in the fields of your new poll document. The default template for rendering this data always shows the text (both when inviting to vote and when presenting the votes). The introduction is only shown when inviting to vote.
The multiple Options field stores your answers. The Value attribute is used internally in the repository for book-keeping, while the Label attribute is typically rendered to the webpage. The rendering code has access to both attributes.
The next step requires that you have created at least one poll document.