This page is still a beta!

1.13. Developers corner

Database relation model

(also available in extension folder powermail/doc/database_relation)

tt_content: Original tt_content field extended with some powermail fields

tx_powermail_fieldsets: Table with all fieldsets

tx_powermail_fields: Table with all fields

tx_powermail_mails: If you submit in a form the values are saved to this table

Hooks in powermail

Introduction

With the possibilitiy of hooks, you can manipulate extensions and TYPO3 without changing the code. So you enter your own code from outside.

Hook documentation

#

Hookname

File

Folder

Function

Input

Return

Note

Example use

1

Real markerArray hook

class.tx_powermail_markers.php

lib

PM_markerArrayHook

$this->what, $this->geoArray, $this->markerArray, $this->sessiondata, $this->tmpl, $this

-

This is the main markerArray hook. Every action in powermail (show confirmationpage, show thx page, show mandatory page, generate email to receiver, generate email to sender) uses the marker class to show fieldvalues. With this you you can manipulate this output as you want

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['powermail']['PM_MarkerArrayHook'][]

2

Adding or changing markers (for all views)

class.tx_powermail_markers.php

lib

PM_FieldMarkerArrayHook

$markerArray, $formValues, $k, $v, $kv, $vv, $this

-

Every marker (confirmation page, mandatory page, thx page, email sender, email receiver) will be using this hook

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['powermail']['PM_FieldMarkerArrayHook'][]

3

Hook for main manipulation1

class.tx_powermail_pi1.php

pi1

PM_MainContentBeforeHook

$this->sessionfields, $this->piVars, $this

-

You can change the sessions or piVars or something like that

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['powermail']['PM_MainContentHookBefore'][]

4

Hook for main manipulation2

class.tx_powermail_pi1.php

pi1

PM_MainContentAfterHook

$this->content, $this->piVars, $this

-

Change the whole output $content

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['powermail']['PM_MainContentHookAfter'][]

5

Hook for page with form

class.tx_powermail_form.php

pi1

PM_FormWrapMarkerHook

$this->OuterMarkerArray, $this->subpartArray, $this->conf, $this

-

This hook will be opened before the outerMarker array is substituted with HTML template on the form page.

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['powermail']['PM_FormWrapMarkerHook'][]

6

Hook for page with form for inner wrap

class.tx_powermail_form.php

pi1

PM_FormWrapMarkerHookInner

$this->InnerMarkerArray, $this->conf, $row, $this

-

This hook allows to change markers in the formwrap (inner loop)

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['powermail']['PM_FormWrapMarkerHookInner']

7

Hook for adding new fields

class.tx_powermail_html.php

pi1

PM_FieldHook

$this->xml, $this->title, $this->type, $this->uid, $this->markerArray, $this->piVarsFromSession, $this

$this->content

This hook allows you to add new fields to powermail (see powermail_mul for an example)

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['powermail']['PM_FieldHook']['FIELDNAME'][]

8

Hook after field generation

class.tx_powermail_html.php

pi1

PM_FieldWrapMarkerHook

$this->uid, $this->xml, $this->type, $this->title, $this->markerArray, $this->content, $this->piVarsFromSession, $this

-

This hook will be opened before the html code of the current field is given back (at the end of fieldgeneration). Maybe if you want to manipulate a special field

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['powermail']['PM_FieldWrapMarkerHook'][]

9

Hook for markerArray in field generation

class.tx_powermail_html.php

pi1

PM_FieldWrapMarkerArrayHook

$this->uid, $this->xml, $this->type, $this->title, $this->markerArray, $this->piVarsFromSession, $this

-

This hook will be used for every kind of field. You can manipulate the markerArray before the field is generated

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['powermail']['PM_FieldWrapMarkerArrayHook'][]

10

Hook for markerArray in field generation (inner markerArray for checkboxes, radiobuttons, and so on)

class.tx_powermail_html.php

pi1

PM_FieldWrapMarkerHookInner

$this->uid, $this->xml, $this->type, $this->title, $markerArray, $this->piVarsFromSession, $this

-

This hook will be used for every kind of field. You can manipulate the markerArray before the field is generated (this hook will be used for innerMarkerArray – checkbox, radiobuttons, etc...)

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['powermail']['PM_FieldWrapMarkerArrayHookInner'][]

11

Hook for manipulation of default markers

class.tx_powermail_html.php

pi1

PM_FieldWrapMarkerHook1

$this->uid, $this->xml, $this->type, $this->title, $this->markerArray, $this->piVarsFromSession, $this

-

Useful if you want to prefill some powermail fields with your own stuff, etc...

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['powermail']['PM_FieldWrapMarkerHook1'][]

12

Hook for confirmation page

class.tx_powermail_confirmation.php

pi1

PM_ConfirmationHook

$this->markerArray, $this

-

This hook will be opened before the marker array is substituted with HTML template on the confirmation page.

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['powermail']['PM_ConfirmationHook'][]

13

Mandatory and error check hook

class.tx_powermail_mandatory.php

pi1

PM_MandatoryHook

$this->error, $this->markerArray, $this->innerMarkerArray, $this->sessionfields, $this

-

If you set $this->error to 1, powermail will stop the submit process, with $this->sessionfields you can write your own error message

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['powermail']['PM_MandatoryHook'][]

14

Hook for email change

class.tx_powermail_submit.php

pi1

PM_SubmitEmailHook

$this->subpart, $this->maildata, $this->sessiondata, $this->markerArray, $this

-

This hook allows to change the emails (subject, receiver, sender, etc..)

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['powermail']['PM_SubmitEmailHook'][]

15

Submit hook before submit

class.tx_powermail_submit.php

pi1

PM_SubmitBeforeMarkerHook

$this, $this->markerArray, $this->sessiondata

Errorcode (0/1 bolean)

If you want to stop the submit (emails and db insert), you can return TRUE

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['powermail']['PM_SubmitBeforeMarkerHook'][]

16

Submit hook after emails

class.tx_powermail_submit.php

pi1

PM_SubmitAfterMarkerHook

$this, $this->markerArray, $this->sessiondata

-

If you want to do something after a correct submit, you can use this hook (maybe an additional db entry)

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['powermail']['PM_SubmitAfterMarkerHook'][]

17

Thx message hook

class.tx_powermail_submit.php

pi1

PM_SubmitLastOneHook

$this->content, $this->conf, $this->sessiondata, $this->ok, $this

-

If you want to manipulate the thx message after submit

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['powermail']['PM_SubmitLastOne'][]

How to use a hook in my own extension?

Example for using a powermail hook in your own extension in the ext_localconf.php:

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['powermail']['PM_FormWrapMarkerHook'][] = 'EXT:yourextension/targetphpfile:tx_yourphpclass';

This hook want to use the function PM_FormWrapMarkerHook() in your class

Note: The class name must start with a tx_

Additional information

Hook documentation is also available in extension folder powermail\doc\hook

  1. hooks.ods could be open with OpenOffice

  2. hooks.html can be read with a browser

Look into another extension which uses a powermail hook to manipulate powermail

The antispam extension wt_spamshield uses two powermail hooks, look into the code, if you want to know more:

http://typo3.org/extensions/repository/view/wt_spamshield/0.1.6/

Do you need a new hook?

Do you need a special hook? Write us!