DEPRECATION WARNING

This documentation is not using the current rendering mechanism and is probably outdated. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.

EXT: Poll

Author:Kasper Skårhøj
Created:2002-11-01T00:32:00
Changed by:Kasper Skårhøj
Changed:2002-11-30T01:41:18
Email:r.fritz@colorcube.de
Info 2:
Info 3:
Info 4:

EXT: Poll

Extension Key: tt_poll

Copyright 2000-2002, , <r.fritz@colorcube.de>

This document is published under the Open Content License

available from http://www.opencontent.org/opl.shtml

The content of this document is related to Typo3

- a GNU/GPL CMS/Framework available from www.typo3.com

Table of Contents

EXT: Poll 1

Introduction 1

Configuration 2

Files 2

Description 2

Static template 2

pollLib.inc properties 2

Introduction

img-1

Please note that the poll plugin is not enabled by default in typo3. You have to include the file poll_extTables.inc in typo3conf/localconf.php.

Set in localconf.php:

$typo_db_extTableDef_script = “extTables.php”;

Add/set/uncomment in extTables.php:

include(PATH_site.”media/scripts/poll_extTables.inc”);

Configuration

Files

pollLib.inc

File

pollLib.inc

Description

Main class used to display the poll abject.Call it from a USER cObject with 'userFunc = user_poll->main_poll'

poll_submit.inc

File

poll_submit.inc

Description

Used with FEDATA to submit user poll values to the database.See static_template 'plugin.tt_poll'.

poll_extTables.inc

File

poll_extTables.inc

Description

This file extend the definition in tables.php. Look above for set up.

Description

The poll object consist of the two files pollLib.inc (display) and poll_submit.inc (calculation and submission to the database).

The pollLib.inc is able to display two parts which are selected through the .code option. The first part is the vote form where the user can make his vote. The second part is the result which may show some graphs.

You maybe want to limit the poll to a period. You can set this limit with the tt_poll.starttime and tt_poll.endtime values. If the start time is in the future nothing will be shown. If the start time is in the past and the end time is in the future the poll is in progress and the vote form and the result are both displayed. If the end time is in the past the poll is finished and only the result will be displayed. If the end time is not set the poll has an open end.

The polls choices/answers are stored in tt_poll.answers in format:

129|coffee
45|tea
4|milk

means 129 votes for coffee, 45 for tea and 4 votes for milk.

During the voting a cookie will be set in poll_submit.inc to prevent multiple votings from one user. This is not really safe, because the user can delete the cookie or he switched cookies off.

If a backend user vote, no cookie will be written. This is to make it comfortable to test the poll for backend users.

Usage from tt_content.records

This would be the normal way to display the poll. This is used in the static_template 'plugin.tt_poll'.

Usage from another object

If you need a poll for another record and a link to, it should be done through TypoScript where you simply insert your poll object as a content element in a COA or whatever renders your element.

Example:

= COA
10 = LOAD_REGISTER
10.tt_whatever_uid.field = uid

20 = < plugin.tt_poll
20.pollTable = tt_whatever
20.pollTableUid.data = register : tt_whatever_uid

The record field tt_poll.linkrecord has to be set with a 'record link':

tt_whatever_uid

Example:

tt_whatever_23
Example:

See static_template 'plugin.tt_poll' for a working configuration.

Static template

plugin.tt_poll

pollLib.inc properties

pollTable

Property

pollTable

Data type

string

Description

Normally the poll has it's data already because it's the current record, so this is not needed.

This is used to get a connection from another table to a poll record. Example: you created your own table user_images which shows a photo gallery. This option allows you to link a poll

The first pid from .pid_list is used to store new created record, otherwise the current page will be used.

To enable this feature, you have to set this option with the name of the table y

See 'Usage from another object'

Default

pollTableUid

Property

pollTableUid

Data type

string / stdWrap

Description

This is used to get a connection from another table to a poll record. If not set cObj->currentRecord is used.

See 'Usage from another object'

Default

Current record

pollTablePid

Property

pollTablePid

Data type

string / stdWrap

Description

This is the pid which holds the poll record. If not set the current page is the pid.

See 'Usage from another object'

Default

current page

code

Property

code

Data type

string / stdWrap

Description

Code to define, what the script does. Case sensi tive

VOTEFORM : Shows a form from which to vote for the poll.

RESULT : Shows the polls result (.resultObj).

SUBMITTEDVOTE : Shows the just submitted vote from the user.

Default

date_stdWrap

Property

date_stdWrap

Data type

stdWrap

Description

stdWrap for tt_poll.starttime (###STARTTIME###) andtt_poll.endtime (###ENDTIME###)

example:

date_stdWrap.strftime= %e-%m-%y

Default

pollOutputWidth

Property

pollOutputWidth

Data type

integer

Description

If you want to create a bar this is the full (100% of votes) length.See also .resultItemObj .

Default

wrap

Property

wrap

Data type

wrap

Description

Wraps the whole output.

Default

voteform

Property

voteform

Data type

FORM

Description

There's only one form element to set up in this form:

voteform.dataArray {
    10.type = formtype_db = submit
    10.value = Vote
}

The poll items are set up from the script.

If you want to show the result on another page you have to set the voteform.redirect property.

For the rest of the FORM set up, have a look at the FORM description.See also the plugin.tt_poll TypoScript example.

Default

resultItemObj

Property

resultItemObj

Data type

cObject

Description

Render object for every poll answer/item.

Following strings will be substituted:

###ANSWER###poll item text

###ITEMVOTES###tt_poll.votes, count of all votes

###PERCENT###percentage of the items vote from all votes

Following values are usefull to create bars:

###POLLFULLWIDTH###This is the full length (100%) of a bar or something similar(= .pollOutputWidth)

###POLLWIDTH###This is the width of a bar or something similar

###POLLREMAINWIDTH###POLLFULLWIDTH – POLLWIDTH

Default

resultObj

Property

resultObj

Data type

cObject

Description

This is the object to output the result. Have a look at the plugin.tt_poll TypoScript example.

In this object there will be done a few string substitutions. This is for output poll values.

Following strings will be substituted with other objects output:

###RESULTITEMS###All items (the list) rendered with .resultItemObj

###PROGRESSMSG###If tt_poll.starttime and/or tt_poll.endtime is set,this marker will be substituted with.inProgressObj Or .finishedObj .

###VOTESMSG###If tt_poll.starttime and/or tt_poll.endtime is set,this marker will be substituted with.submittedVoteObj .

Following string substitutions will be done:

###TOTALVOTES###tt_poll.votes, count of all votes

###TITLE###tt_poll.title

###QUESTION###tt_poll.question – your poll question

###SUBMITTEDVOTE###The submitted vote text

###STARTTIME###tt_poll.starttime

###ENDTIME###tt_poll.endtime

See also the plugin.tt_poll TypoScript example.

Default

inProgressObj

Property

inProgressObj

Data type

cObject

Description

Used if the poll is in progress and has a end date. Then it will substitute ###PROGRESSMSG###. Could display a message like:

The Survey will end at ###ENDTIME###

Default

finishedObj

Property

finishedObj

Data type

cObject

Description

Used if the poll is over. Then it will substitute ###PROGRESSMSG###. Could display a message like:

The Survey was finished at ###ENDTIME###

Default

submittedVoteObj

Property

submittedVoteObj

Data type

cObject

Description

Used if the user just voted and .code includes SUBMITTEDVOTE. Then it will substitute ###VOTEMSG###. Could display a message like:

Your vote was: “###SUBMITTEDVOTE###”

Default

[tsref:(script).pollLib]

img-2 EXT: Poll - 4