Skip to content

nuex/radiant-polls-extension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Polls Extension

Web polls for Radiant CMS.

Installation

Via Git Submodules:

git submodule add git://github.com/nuex/radiant-polls-extension.git vendor/extensions/polls
rake radiant:extensions:polls:migrate
rake radiant:extensions:polls:update

This extension uses will_paginate to allow you to create a paginated list of “archived” polls. You must provide the will_paginate gem; it is not included with this extension.

Usage

<r:poll title="My Poll">
  <r:unless_submitted>
    <r:form>
      <r:options:each>
        <p><r:input /> <r:title /></p>
      </r:options:each>
      <r:submit />
    </r:form>
  </r:unless_submitted>

  <r:if_submitted>
    <table>
      <tr>
        <th>Answer</th>
        <th>Result</th>
      </tr>
      <r:options:each>
        <tr>
          <td><r:title /></td>
          <td><r:number_responses /> (<r:percent_responses />)</td>
        </tr>
      </r:options:each>
    </table>
  </r:if_submitted>
</r:poll>

If polls are defined with a start date, then the current poll (defined as the poll that has the latest start date that is no later than the current date) can be accessed without the use of the title attribute (i.e., <r:poll>…</r:poll>).

Poll “archives” can also be listed, using pagination via the will_paginate plugin.

<r:polls per_page="10" by="start_date" order="desc">
  <r:each:poll>
    <p><r:title /></p>
    <table>
      <tr>
        <th>Answer</th>
        <th>Result</th>
      </tr>
      <r:options:each>
        <tr>
          <td><r:title /></td>
          <td><r:number_responses /> (<r:percent_responses />%)</td>
        </tr>
      </r:options:each>
    </table>
  </r:each:poll>
  <r:pages />
</r:polls>

Note and Caveats

If you are using the Oracle Enhance Adapter, you may want to add this to your environment.rb,
in the after_initialize block:

# By default, OracleEnhancedAdapter typecasts all columns of type DATE to Time or DateTime.
# This will force DATE values with hour, min and secs equal to 0 to be typecasted to Date.
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates = true
# The above can obviously cause problems, therefore this is to be preferred,
# since it will typecast to DATE, only columns with “date” in their name (e.g. “creation_date“)
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true

Acknowledgements

Thanks to David Coto (github.com/davec) for the many enhancements and specs.

The date picker uses Dan Webb’s LowPro library and its associated date_selector behavior.

The pagination related code was borrowed liberally from the paginate extension, especially saturnflyer’s enhancements to it (github.com/saturnflyer/radiant-paginate-extension).

About

Adds web polls to Radiant.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published