Poll Position: Configure


While Poll Position is now installed, there are still a few steps you need to take to get it working: adjust plugin Settings, and create and modify templates.

Modify Plugin Settings

FirefoxScreenSnapz003.png

Within a Website or Blog, visit the Tools menu and choose Plugins, then find Poll Position and view its settings. There are several options to configure how everything works.

Poll Position can be enabled to support polls, quizzes, or both with the Enable Poll Position option.

The Republish Index Template field helps make it easy to publish a poll or quiz. Selecting a template to republish, combined with a cached template module or widget, can provide a fast and effective way to update your entire site with the latest poll, for example.

Use the Voting Frequency field to control how often a visitor can vote in a poll or quiz: one time only, daily, or voting can be unrestricted.

To maintain strict control over who can vote in a poll or quiz, Require Authentication. This forces users to log in to participate, and can be disabled, enabled for all, or configured on a per-poll/quiz basis.

Restrict Votes by IP to try to identify users by their IP address, so that the Voting Frequency selection can be enforced. Note that setting the Voting Frequency to Unrestricted causes this setting to have no effect.

Poll and quiz results can be built with an HTML template. Poll results can be more simply built by using the built-in Google Charts support, and the following options offer some configurability to this function.

  • The Chart Size option is where you can specify the width or your Google Charts bar chart image. The height of the chart is automatically calculated by Poll Position based on the number of response choices you’ve created and the bar chart height and spacing.

  • The thickness of the bar generated by Google Charts can be set using the Chart Bar Thickness option. This option is specified in pixels, and only a numeral needs to be entered here.

  • Similar to the Chart Bar Thickness option, the Space Between Bars value is a pixel number and only a numeral is entered. As the name says, this controls the space between each bar result.

  • Surely, you’ll want to control the colors used in your poll’s result. The Chart Colors option is where you do this. You have the option to specify both the foreground (chart bar) and background colors. Specify these as six-character hex values, without the leading pound sign. The background also supports transparency, in the way of a 2-character hex value: ff is fully transparent and 00 is fully opaque. Note that any color used with the ff transparency will be fully transparent — ffffffff (transparent white) will appear the same as 000000ff (transparent black).

Be sure to save your changes after selection options.

Add Required Templates

There are a few new templates you’ll need to add — as well as modifications to your existing templates that need to be made — to allow visitors to interact with polls on your site. In the folder plugins/PollPosition/default_templates/ you’ll find the required templates.

pollposition.js.mtml is the Javascript that lets Poll Position do it’s thing. Create a new index template and copy-paste this code into it. Be sure to name the template and fill the Output File field before saving and publishing (I called mine “Poll Position Javascript” and pollposition.js).

Within pollposition.js.mtml you may have noticed that some jQuery code was used. You’ll next want to edit your templates to add jQuery and the Poll Position Javascript to your published pages. The following snippet should be placed between the <head> ... </head> tags or at the end before </body> of any page you want to display a poll on:

<script type="text/javascript" src="<mt:StaticWebPath>support/plugins/pollposition/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="<mt:StaticWebPath>support/plugins/pollposition/jquery.form.js"></script>
<script type="text/javascript" src="<mt:BlogURL>pollposition.js"></script>

Of course, those paths should reflect where the files actually exist, if different, and jQuery only needs to be included once on a page.

A template is used to return a response to the user after participating in a poll or quiz. A Global Template named “Poll Position Results” was automatically created during configuration; if blog-level control is preferred, create a Template Module named “Poll Position Results”; plugins/PollPosition/default_templates/poll_position_results.mtml is an example to get started with.

Additionally, in plugins/PollPosition/default_templates/ you’ll find poll.mtml, which is an example form suitable for display a poll or quiz. Add this as a Widget or Template Module to insert into any other template you want to show a poll/quiz in. Set this Widget or Template Module to use Server Side Includes and include it in the Index Template you’ve set to republish when a poll or quiz is saved, and you’ve just created a workflow that keeps the latest poll or quiz on all pages of your site!

A custom Poll Position Results response template can be used, of course. Poll Position sends response information in the JSON format, and includes several pieces of data that are useful for processing the response. Refer to pluginsPollPosition/default_templates/pollposition.js.mtml for examples of the JSON use.

  • type can be one of the following: invalid, unpublished, voting_closed, unauthorized, already_voted, vote_successful, results_only, or error.
  • message contains a human-readable description of the type.
  • freq returns the Voting Frequency selection from the plugin Settings.
  • restrict_ip returns a true/false flag showing the Restrict IP selection from the plugin Settings.
  • results contains the HTML built from the Poll Position Results template.

Poll or Quiz Custom Field Type

FirefoxScreenSnapz004.png

Poll Position includes a “Poll or Quiz” custom field type. This can be used to allow authors to select a poll to include in an entry, for example. Create a system- or blog-level Custom Field and select the “Poll” type to create the field. The template tag created for this field will return a poll ID, which you can use with the IfPollIncluded template tag to output a poll. This feature requires the Movable Type Commercial.pack, part of Movable Type Pro.

When creating an entry (or wherever the Custom Field was defined for display), the author will be able to click a “Choose Poll or Quiz” button that displays a popup dialog they can select a poll or quiz from. After selection, a red “x” makes it easy to delete that selection.

Poll or Quiz Config Type

Poll Position includes a “Poll or Quiz” config type, which the Config Assistant plugin uses to display Theme Options, making blog-level customization super-easy. Theme developers can simply specify the type in their theme as poll_position — polls or quizzes will be selectable depending upon what objects have been enabled in the plugin Settings.

Just as with the Custom Field type, the resulting interface is a button that causes a popup dialog to appear where the author can select their poll or quiz.