Pre-subscription hook. The variable $hookAbort is passed into the expected method. If you implement this as an reference in your hook handler, you can abort the subscription an the user will get an error message...
if (is_array ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey][$this->prefixId]['subscription'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey][$this->prefixId]['subscription'] as $classRef) {
$hookObj= &t3lib_div::getUserObj($classRef);
if (method_exists($hookObj, 'startSubscription')) {
$hookObj->startSubscription($MA, $MACourse, $MAEvent, $MATrainer, $MALocation, $hookAbort, $this);
}
}
}
The parameters prefixed with $MA are associative marker arrays for template substitutions. $this is the PHP common reference to the current object. In this case, the pi1 class instance.
This hook is called just before the output of the displayDetail Method renders the detailed View of an course. That is the hook:
if (is_array ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey][$this->prefixId]['displayDetail'])){
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey][$this->prefixId]['displayDetail'] as $classRef){
$hookObj= &t3lib_div::getUserObj($classRef);
if (method_exists($hookObj, 'customDisplayDetail')) {
$hookObj->customDisplayDetail($sRet,$MACourse);
}
}
}
Your method customDisplayDetail MUST receive the parameter as Reference to take an effect!!!
This hook is called just before the method fillAllLabels returns. The method fills an array with general markers and is used for substitution before the output of each view type! So you can use this hook to add different labels.
Thats the hook:
if (is_array ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey][$this->prefixId]['fillAllLabels'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey][$this->prefixId]['fillAllLabels'] as $classRef){
$hookObj= &t3lib_div::getUserObj($classRef);
if (method_exists($hookObj, 'customFillAllLabels')) {
$hookObj->customFillAllLabels($MA);
}
}
}
Due to the fact that a submitted subscription form is not stored in any way by this extension currently, you can add as many fields as you want. If you want the submitted data to be stored anywhere, you can use the subscription hook for this. Of course, that means you have to do some coding.
However, add some fields to the subscription form does not require any coding skills.
Here an example. Expecting you have a form-template with input fields for firstname, surname and email, the template would look like this:
<!-- ###SUBSCRIBEFORMTMPL### begin -->
<h2>###LABELSUBSCRIBEHEADER###</h2>
###LABELWARNING###
###WARNING###
<form action="###PATHSUBSCRIBE###" method="POST">
The next 3 lines are the input fields!
###LABELNAME### <input type="text" name="vorname" value="###VORNAME###"/><br />
###LABELLASTNAME### <input type="text" name="nachname" value="###NACHNAME###"/><br />
###LABELEMAIL### <input type="text" name="email" value="###EMAIL###"/> <br />
<input type="hidden" name="subscribe" value="1" />
<input type="hidden" name="eventid" value="###EVENTID###" />
<br />
<input type="submit" value="###LABELSUBMITSUBSCRIBE###" />
</form>
<!-- ###NOSUBSCRIBEFORMTMPL### begin -->
###LABELERRORCONTACTUS###<br>
###LINKCATOVERVIEW###<br>
###LINKDETAILSEARCH###
<!-- ###NOSUBSCRIBEFORMTMPL### end -->
<!-- ###SUBSCRIBEFORMTMPL### end -->
And now, we want to add an required input field where the subscriber should enter the name of the company he is working for. We call the input field “company”.
For a new Input field we can:
create a new localized template marker for the label of the field as shown on the rendered subscribing form
create a new localization for the rendered mails
define the new field as “required” input
suppress or show the field in the generated mail
Especially the last point is usefull if you integrate some hidden form fields which may be required within your subscription hook.
At first, you add one line in the template of you form:
<input type="text" name="company"/><br />
But now you have only an input field. You want to have a localized label as well. So you add a marker for the label:
###ADDONLBL-COMPANY### <input type="text" name="company"/><br />
Now, add “addonlbl-company” to the comma separated list of the plugins TS configuration. This is explained above in the section “TS Configuration”. And of course, add one line to the pi1's locallang.xml file. Use the key “addonlbl-company” for the index attribute of the new line in the XML file. Do not forget: f you update abcourses later, make a backup of you locallang.xml to play save!
We want the new form field to be stikky. That means, that the input of the field is not deleted if the subscriber returns to the subscribing form in case of a failed form validation. So, add the “value” attribute to the new form field and insert a marker. The marker must be the uppercase “name” attribute of the form field, but with 3 # prefixed and post-positioned.
###ADDONLBL-COMPANY### <input type="text" name="company" value=”###COMPANY###”/><br />
The first step is done now. You have a new line in your form, made it stikky, added a label and localized it. Great ;-)
But what is about the “required” setting as mentioned above? And where to find the visibility settings? Go back to the TS Configuration and you will find some description for the template marker: usedLabels, required, mailLabels.
For our example setup it should look like this:
# ALL fields of the form must be listed here!!!usedLabels = vorname, nachname, email, subscribe, eventid, company
# Here you list all fields that you wants to be reuired!!!required = email, company
# And last but not least: list all labels that you wants to appear within the sent mails.mailLabels = vorname, nachname, email, company
One more hint! The name of the field “email” is automatically validated as an email address and will be used as the sendTo recipient for the customers confirmation email.
Thats it! I hope this quick overview was usefull for you.
Within the email template you will find a marker ###FORMDATA###.
This marker will be replaced by the _POST variables of the subscription form. For each key>value pair their will be one new line rendered.
Please note that you have to define the values, which you want to be included in this listing, within the TS setup variable “mailLabels”.
By example: The _POST variable “company” will be rendered like this:
Company : XYZ AG
But where comes the “Company” from? Abcourses tries to look up every POST key in the locallang.xml. If you added there a line with “company” as index, you can localize the form field labels for the mail template.
If abcourses do not found a localization, it uses the key of the field as label with an upper cased first letter.
Please consider that you should not choose key names which already exists in the locallang.xml!