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 <extension3>th_mailformplus</extension3>.

You have to add the following code in typo3conf/ext/th_mailformplus/pi1/class.tx_thmailformplus_pi1.php <PHP> 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 .= "
  • ".ucfirst($key); } } } } [...]
    1. file uploads!
    2. if a file upload directory is specified in TypoScript
    3. filename: [pageID]_[newRecordID].[filetype]
    </PHP> 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> 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})$ </TS> This information is from http://wissen.hgplaza.de/66.html

    [edit] Prefilled fields

    <TS>

    # 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 = {GPvar:userid}|
            # take the email of the selected user
     	 defaultValue.wrap3 = {DB:fe_users:|:email}
     	 defaultValue.insertData = 1
      }
    }
    

    </TS>


    [edit] 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)
    
  • Personal tools