This page is still a beta!

1.6. Hooks

Using hooks

This section explains how to use hooks inside Comments extension and lists all available hooks.

New hooks can installed using the following code in ext_localconf.php of another extension:

$TYPO3_CONF_VARS['EXTCONF']['comments'][hookName][yourextkey] = 'EXT:yourextkey/class.tx_yourextkey_hooks.php:&tx_yourextkey_hooks->methodName';

Notice that you can freely choose method name for the hook.

Common hook parameters

Each hook receives two arguments:

Argument:

Type:

Description:

&$params

array

Contains hook parameters (specific for each hook, see hooks list below) and 'pObj', which is identical to $pObj hook parameter.

&$pObj

tx_comments_pi1

Reference to calling class. Notice that you should have “&” before this parameter name.

List of hooks

Section name in this chapter corresponds to hookName in section “Using hooks”.

closeCommentsAfter

This hook is called when comments extension must decide if commenting is closed for item. Parameters:

Argument:

Type:

Description:

table

string

Table name

uid

int

uid of the record

Hook should return integer Unix time value to indicate if item is closed. Returning “false” means “do not know”. The first integer value stops processing of other hooks.

comments

This hook is called when marker array is prepared for displaying comments list as whole. Parameters:

Argument:

Type:

Description:

template

string

Template subsection to be used

markers

array

Existing markers

Hook should return a modified array with markers.

comments_getComments

This hook is called when marker array is prepared for displaying a single comment in a list. Parameters:

Argument:

Type:

Description:

template

string

Template subsection to be used

markers

array

Existing markers

row

array

Current comment row

Hook should return a modified array with markers.

externalSpamCheck

This hook is called when comments extension checks messages for spam. Hook can add or remove spam points based on its own logic. Parameters:

Argument:

Type:

Description:

formdata

array

A shortcut $pObj->piVars

points

int

Currently earned points

Hook should return integer value, which will be added to current numver of spam points. To block message completely, accumulated points value must be greater than “spamProtect.spamCutOffPoint”.

eID_postProc

This hook is called by eID script when comments extension approves or deleted comment using link in notificatiion e-mail. It allows to post-process e-mail commands. Hook does not receive anu custom parameters.

form

This hook is called when marker array is prepared for displaying form. Parameters:

Argument:

Type:

Description:

template

string

Template subsection to be used

markers

array

Existing markers

Hook should return a modified array with markers.

mergeConfiguration

This hook allows to alter/add configuration values for tx_comments_pi1. There are no additional parameters to the hook. Hook should modify configuration in the following way:

$pObj->conf['section.']['param'] = 'value';

processSubmission

This hook is executed before record is inserted into database.

Argument:

Type:

Description:

record

array

Record array

Hook should return a modified record array.

sendNotificationMail

This hook is called when marker array is prepared for sending e-mail notification to administrator. Parameters:

Argument:

Type:

Description:

template

string

Template subsection to be used

check

string

Hashed check value for eID call

markers

array

Existing markers

Hook should return a modified array with markers.

processValidComment

This hook is called when comment is posted and visible on the web site. It is not called when comment is approved by the administrator manually! Parameters:

Argument:

Type:

Description:

uid

integer

uid of the new comment record

Return value is ignored.