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: Ratings

Author:Kasper Skårhøj
Created:2002-11-01T00:32:00
Changed by:Michiel Roos
Changed:2010-08-05T13:21:40
Author:Netcreators BV
Email:extensions@netcreators.com
Info 3:
Info 4:

EXT: Ratings

Extension Key: ratings

Copyright 2007-2009, Netcreators BV, <extensions@netcreators.com>

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: Ratings 1

Introduction 1

What does it do? 1

Screenshots 1

Users manual 2

Rating pages 2

Rating tt_news items 2

FAQ 2

Adminstration 2

FAQ 3

Configuration 3

FAQ 4

Ratings PHP API 4

Terms 5

Accessing API 5

API reference 5

Known problems 5

To-Do list 5

Translating the extension 6

ChangeLog 6

Introduction

What does it do?

This extension provides:

  • A frontend plugin for displaying and adjusting ratings
  • An AJAX-based voting (extremely fast!)
  • A highly customizable look for ratings (template and/or css file)
  • Several image sets for ratings
  • An API for other extensions to integrate ratings into their records (for photos, news, articles, comments, etc)
  • A set of hooks to popular extensions to enable the rating functionality inside of them

The extension requires PHP 5.1 or newer. It will not work with PHP 5.0 or older versions. There is no direct dependency on the TYPO3 version but bugs are not accepted if the TYPO3 version is older than current official major TYPO3 version (4.1 in January 2008).

This extension was created by Dmitry Dulepov for Netcreators BV.

Screenshots

Default view, user did not vote yet:

img-1

Default view, user already voted:

img-2

The following images are shipped with this extension to use in ratings:

img-3 The first image column describes the “not voted” state, second is “votes” and the images in third column appear when a visitor hovers over the voting bar. All these images are either licensed under GPL or the Creative Commons license. The respective Copyright information is provided in the CSS file that use these images. See the Configuration section for details.

Users manual

Rating pages

To use ratings for a page, the TS template of the ratings extension has to be added to the page. The extension will work out of the box with the default options. See the configuration section in this manual if any option needs to be adjusted.

As a next step, add the ratings plugin to the page. It is possible to override the storage page ID and template file location through the plugin. Now users can rate the pages!

Rating tt_news items

To use ratings for tt_news, the TS template of the ratings extension has to be added to the page. The extension will work out of the box with the default options, however if you need to modify the options, see the Configuration section for details.

Insert the ###TX_RATINGS###marker into your tt_news template. Web site visitors now can rate news items. If the rating should not appear on a particular news item, clear the corresponding box when editing a tt_news record.

FAQ

None yet

Adminstration

There is no special information for administrators.

FAQ

Non yet

Configuration

This section describes TypoScript configuration.

storagePid

Property

storagePid

Data type

integer

Description

Page uid where all the rating records are stored.

Default

empty (value of {$plugin.tx_ratings_pi1.storagePid} constant)

templateFile

Property

templateFile

Data type

string

Description

Template file for the plugin. Accepts either a site-relative path or an extension-related path (EXT: prefix)

Default

EXT:comments/res/pi1_template.html (value of {$plugin.tx_ratings_pi1.templateFile} constant)

minValue

Property

minValue

Data type

integer

Description

Minimum rating value. This must not be changed once ratings are in use already. Changing this value also requires CSS adjustments (length of voting bar).

Default

1

maxValue

Property

maxValue

Data type

integer

Description

Maximum rating value. This must not be changed once ratings are in use already. Changing this value also requires CSS adjustments (length of voting bar).

Default

5

ratingImageWidth

Property

ratingImageWidth

Data type

integer

Description

Width of a single rating bar image. Must be adjustted if a non-default image is used.

Default

11

mode

Property

mode

Data type

auto or static

Description

“auto” means that ratings will operate as they normally do on web sites (user votes and he cannot vote on this item any more). “static” means that the user will not be able to vote: ratings will be read- only.

Default

auto

disableIpCheck

Property

disableIpCheck

Data type

boolean

Description

Disables the IP address check for votings. If this check is disabled, users may vote any number of times on the item (useful for testing). Notice: users will have to reload the page to vote again!

Default

0

additionalCSS

Property

additionalCSS

Data type

string

Description

Allows to change the appearance of ratings without changing template. Typically ratingImageWidth needs to be changed too.

There are several predefined CSS files that can be reused:

See the Screenshots section for examples of images. Other royalty free images can be included (send them to me by e-mail).

(Note to copyright owners: since you give your scripts for free, I (Dmitry Dulepov, dmitry@typo3.org) took liberty to use images and provide references to your web sites to honor your great work. However, if you feel that your images should be removed, drop me a message by e-mail. Providing this images with this TYPO3 extension is entirely my personal idea and I alone should be responsible for this action. By I do hope that you are not against using these images in Open Source software.)

Default

FAQ

Q: I disabled IP check but after I rate the item, I cannot rate it again!

A: You need to reload page to rate again. This is a technical limitation due to the usage of AJAX.

Q: I included another CSS but the images are cut or clicks do not work properly

A: You forgot to adjust theratingImageWidth parameter. See the Configuration section.

Q: I try to use the extension with TYPO3 3.x/4.0 but...

A: Sorry, but this extension is not tested and will not be supported under any TYPO3 version below 4.1.

Q: I try to use the extension but PHP errors show up

A: Your PHP version is lower than 5.1. The ratings extension does not work with PHP versions lower than 5.1.

Q: Can each content item on the page be rated?

A: Not out of the box. This feature can be added if you'd like to sponsor it (665€).

Ratings PHP API

This section is meant for extension developers who want to integrate the ratings functionality into their extensions. The frontend plugin of the ratings extension itself is actually a simple wrapper around this API.

Terms

This section defines some terms used by the API.

Element

Term

Element

Data type

N/A

Description

Any item to rate. It can be a page, content element, article, image or any other item that can be identified in any way.

Reference

Term

Reference

Data type

string

Description

Unique identifier of the element . It must uniquely identify an element among any other element within TYPO3. The Ratings API does not care about the format of the reference as soon as it can be saved into a varchar(255) database field. However it is strongly recommended to use the standard TYPO3 “group” format for it, which consists of the table name, an underscore and the uid of the item (for example, “tt_content_10”, “pages_20” or “tx_myext_data_88”).

Configuration

Term

Configuration

Data type

array

Description

In order to calculate or display ratings, the API needs to know certain configuration parameters. If supplied by the caller, it expects an array with parameters described in the “Configuration” section of this manual. If the configuration is not supplied by the caller, the API will use “plugin.tx_ratings_pi1” from the TypoScript setup of the current page. If none of these two is available, the results of the API will be unpredictable. If there is no configuration, the API will result in an error.

Accessing The API

The ratings extension provides PHP class, which implements a set of functions to find the rating for the element or display the attached ratings. The rating modification feature is built into this display feature.

To access the API class, include a class definition into your own plugin class:

if (t3lib_extMgm::isLoaded('ratings')) {
        require_once(t3lib_extMgm::extPath('ratings', 'class.tx_ratings_api.php');
}

Notice the usage of t3lib_extMsg::isLoaded(). This allows you not to have any hard dependency on the ratings extension in your own extension but rather a service that is used if the extension is installed.

As a next step, instantiate the API class in the place where you need to use it:

$ratingsAPI = t3lib_div::makeInstance('tx_ratings_api');

It is important to use t3lib_div::makeInstance() for instantiating the API class. Avoid using the PHP operator “new” for this purpose.

When the class is instantiated, it is ready to be called. There is no futher initialization necessary. All functions are independent and can be called in any order.

API Reference

This section describes each function and parameters in detail. Please make sure to have read the Terms chart in this chapter before reading the section below.

getDefaultConfig
return value

Parameter

return value

Data type

array

Description

Default configuration

Default

getRatingValue
$ref

Parameter

$ref

Data type

string

Description

Reference to the element

Default

$conf

Parameter

$conf

Data type

array

Description

API configuration . If not provided, the default will be used.

Default

null

return value

Parameter

return value

Data type

float

Description

Rating value in percent (from 0 to 100)

Default

getRatingDisplay
$ref

Parameter

$ref

Data type

string

Description

Reference to the element

Default

$conf

Parameter

$conf

Data type

array

Description

API configuration . If not provided, the default will be used.

Default

null

return value

Parameter

return value

Data type

string

Description

HTML generated by for this element

Default

Known problems

None yet

To-Do list

Implement a backend module to explore recorded ratings

Translating the extension

Translation of the extension happens exclusively through the main TYPO3 translation server. If you do not know what the translation server is, read about it here .

ChangeLog

See the ChangeLog file inside the extension.

img-4 EXT: Ratings - 6