Translations
Info
All page names need to be in English.
en da  de  fr  it  ja  km  nl  ru  zh

Th mailformplus

From TYPO3Wiki
Jump to: navigation, search

This is just a short snippet allowing to verify a user input via regular expressions in the extension th_mailformplus.

You have to add the following code in typo3conf/ext/th_mailformplus/pi1/class.tx_thmailformplus_pi1.php
PHP script:
function check_form($content,$conf) {
[...]
foreach ($this->get_post as $key => $value) {
 if (isset($conf["check."][$key])) {
  if (!preg_match(
   "/".str_replace("/","\/",$conf["check."][$key])."/",
   $value)) {
   $temp = $GLOBALS["TSFE"]->cObj->getSubpart(
    $this->templateCode_error, 'ERROR_'.$key);
   if ($temp) {
    $error .= $temp;
    $this->errors['###error_'.$key.'###'] =
     $temp;
   } else {
    $error .= "<li>".ucfirst($key);
   }
  }
 }
}
[...]
############################
# file uploads!
# if a file upload directory is specified in TypoScript
# filename: [pageID]_[newRecordID].[filetype]
############################
If you have done this, you can now define a regular expression in your template in the setup section. For example the following code will verify the form field "email" and test whether it is a correct email address:
TS TypoScript:
plugin.tx_thmailformplus_pi1.check.email = ^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z]) ([-\w]*[0-9a-zA-Z])*\.) [a-zA-Z]{2,9})$

This information is from http://wissen.hgplaza.de/66.html

Prefilled fields

TS TypoScript:
 # Example: insert E-Mail-Adress of feuser
 # with parameter &userid=#number#
 # you can insert the email-Adress into the 
 # field "email" 
 plugin.tx_thmailformplus_pi1.fieldConf {
   email {
         # which user should be selected
   	 defaultValue.dataWrap = {GP:userid}|
         # take the email of the selected user
  	 defaultValue.wrap3 = {DB:fe_users:|:email}
  	 defaultValue.insertData = 1
   }
 }

Using Marker

 plugin.tx_thmailformplus_pi1 {
       # using single marker via ###required### in Template
       markers.required = TEXT
	markers.required.value = *
       markers.required.noTrimWrap = |  | |

       # using SUBPART via ###FORM### in Template with additional Template:
 
         ###TEMPLATE_FORM###
         Hello World - this snippet will be included
         ###TEMPLATE_FORM###

	markers.FORM = SUBPART
	markers.FORM.value = ###TEMPLATE_FORM###
 }
 maholtz 13:10, 4 April 2008 (CEST)