Mailformplus (tx mailformplus): Unterschied zwischen den Versionen
| (13 dazwischenliegende Versionen von 5 Benutzern werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
| + | == Datenbankspeicherung == | ||
| + | === Kurzinfo === | ||
| + | ==== 1. Datenbanktabelle anlegen==== | ||
| + | z.B. mit phpmyadmin | ||
| + | ==== 2. TypoScript ==== | ||
| + | <pre> | ||
| + | plugin.tx_thmailformplus_pi1{ | ||
| + | # DB | ||
| + | //einschalten | ||
| + | saveDB = 1 | ||
| + | //Primärschlüssel | ||
| + | saveDB.dbkey=uid | ||
| + | |||
| + | //Tabellenname | ||
| + | saveDB.dbTable = myTable | ||
| + | |||
| + | // Speichere spezielle Werte (mehrerer mit Komma getrennt) | ||
| + | #saveDB.dbinsert = pid:546,hidden:0,CType:textpic | ||
| + | |||
| + | //Mapping => Formularfeld:DB-Feld - nur das wird gespeichert (+ spezial und dbinsert) | ||
| + | saveDB.mapping = studie:studie,anrede:anrede,vorname:vorname,name:name | ||
| + | // Spezielle Mapping Features | ||
| + | #saveDB.specialMapping = 1 | ||
| + | #saveDB.specialMapping.sub_datetime = datum | ||
| + | #saveDB.specialMapping.logIP = ip | ||
| + | |||
| + | //folgende Felder nicht speichern... | ||
| + | #saveLog.exclude = alter | ||
| + | |||
| + | //für Checkboxen Modifizierung der zu speichernden Felder ermöglichen | ||
| + | //für Backend Export | ||
| + | #saveLog = 1 | ||
| + | #saveLog.order = | ||
| + | #saveLog.defaultValue = 0 | ||
| + | |||
| + | //Benutzerfunktion | ||
| + | #saveUserFunc = fileadmin/template/benutzerfunktion/class.tx_mailformplus.php:tx_mailformplus->writeFormData | ||
| + | } | ||
| + | </pre> | ||
| + | |||
| + | ==== Bereiche im HTML-Template ==== | ||
| + | Todo | ||
| + | |||
| + | == Tipps und Tricks == | ||
| + | === Mehrere Felder in ein Datenbankfeld === | ||
| + | saveDB.mapping = surname:name,forename:name | ||
== Post processing der Formularfelder == | == Post processing der Formularfelder == | ||
Es gibt einen Hook den man nutzen kann um nach dem Erfolgreichen senden des Formulars die '''Daten an eigene PHP Skripte''' zu übergeben. | Es gibt einen Hook den man nutzen kann um nach dem Erfolgreichen senden des Formulars die '''Daten an eigene PHP Skripte''' zu übergeben. | ||
| Zeile 63: | Zeile 109: | ||
#saveDB.debug = 1 | #saveDB.debug = 1 | ||
</pre> | </pre> | ||
| + | |||
| + | === Druckversion des Formulars === | ||
| + | '''1. Abschnitt für Printtemplate im mailformplus-HTML-Template:''' | ||
| + | |||
| + | '''Beispiel''' | ||
| + | <pre> | ||
| + | <!-- ###TEMPLATE_PRINT### begin --> | ||
| + | You just filled out the following fields:<br> | ||
| + | Name: ###name###<br> | ||
| + | Subject: ###subject###<br> | ||
| + | <br> | ||
| + | you uploaded the following files: | ||
| + | ###photo### | ||
| + | <br> | ||
| + | ###cv### | ||
| + | <br> | ||
| + | <!-- ###TEMPLATE_PRINT### end --> | ||
| + | </pre> | ||
| + | |||
| + | '''2. Eine Userfunktion zum speichern und übergeben der Session Variable''' | ||
| + | <pre> | ||
| + | |||
| + | <?PHP | ||
| + | #################################### | ||
| + | # example user-function for # | ||
| + | # fetching the PRINT-subtemplate # | ||
| + | #################################### | ||
| + | |||
| + | class user_mailformplus_userfunc { | ||
| + | var $cObj; | ||
| + | |||
| + | # this function returns the "PRINT" subtemplate | ||
| + | # if defined in the mailformplus-template | ||
| + | # replaced with the values the user has filled out. | ||
| + | |||
| + | function user_mailformplusPrint($content,$conf) { | ||
| + | $printVersion = $GLOBALS["TSFE"]->fe_user->getKey("ses","th_mailformplus".$GLOBALS["TSFE"]->id); | ||
| + | if ($printVersion) { | ||
| + | return $printVersion; | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | ?> | ||
| + | </pre> | ||
| + | |||
| + | '''3. Das zugehörige TS Template''' | ||
| + | <pre> | ||
| + | includeLibs.mailformplus_functions = fileadmin/mailformplus_userfunc.inc.php | ||
| + | ################################ | ||
| + | # outputs the PRINT template below normal page content | ||
| + | # main content | ||
| + | ################################ | ||
| + | |||
| + | temp.main_content = COA | ||
| + | temp.main_content { | ||
| + | 10 < styles.content.get | ||
| + | 20 = USER | ||
| + | 20.userFunc = user_mailformplus_userfunc->user_mailformplusPrint | ||
| + | } | ||
| + | |||
| + | ... | ||
| + | |||
| + | page.10.subparts.CONTENT_MAIN < temp.main_content | ||
| + | </pre> | ||
| + | |||
| + | |||
| + | == Verschiedene Beispiele == | ||
| + | === JavaScript zur Validierung und Mailformplus === | ||
| + | <pre> | ||
| + | plugin.tx_thmailformplus_pi1.multiPage.2.js ( | ||
| + | if((document.Formular.bremsassi1.checked==false) && (document.Formular.bremsassi2.checked==false) && (document.Formular.bremsassi3.checked==false)){ | ||
| + | alert('Bremsassistenten - wählen Sie bitte mindestens einen Punkt aus.'); | ||
| + | return false; | ||
| + | } | ||
| + | if((document.Formular.esp1.checked==false) && (document.Formular.esp2.checked==false) && (document.Formular.esp3.checked==false) && (document.Formular.esp4.checked==false)){ | ||
| + | alert('Elektronisches Stabilitätsprogramm - wählen Sie bitte mindestens einen Punkt aus.'); | ||
| + | return false; | ||
| + | } | ||
| + | if((document.Formular.spurassi1.checked==false) && (document.Formular.spurassi2.checked==false) && (document.Formular.spurassi3.checked==false)){ | ||
| + | alert('Spurassistent - wählen Sie bitte mindestens einen Punkt aus.'); | ||
| + | return false; | ||
| + | } | ||
| + | if((document.Formular.acc1.checked==false) && (document.Formular.acc2.checked==false) && (document.Formular.acc3.checked==false)){ | ||
| + | alert('Automatischer Abstandsregeltempomat - wählen Sie bitte mindestens einen Punkt aus.'); | ||
| + | return false; | ||
| + | } | ||
| + | if((document.Formular.nvs1.checked==false) && (document.Formular.nvs2.checked==false) && (document.Formular.nvs3.checked==false)){ | ||
| + | alert('Nachtsichtassistent - wählen Sie bitte mindestens einen Punkt aus.'); | ||
| + | return false; | ||
| + | } | ||
| + | |||
| + | ) | ||
| + | </pre> | ||
| + | === Beispiel mit verschiedenen Validierungen und Upload-Feld=== | ||
| + | <pre> | ||
| + | plugin.tx_thmailformplus_pi1{ | ||
| + | #email_requiredfields = email,name | ||
| + | #email_attachment = ###fsvorne### | ||
| + | #email_sendtouser > | ||
| + | #debug = 1 | ||
| + | |||
| + | } | ||
| + | |||
| + | plugin.tx_thmailformplus_pi1.fieldConf { | ||
| + | name { | ||
| + | errorCheck = required | ||
| + | } | ||
| + | strasse { | ||
| + | errorCheck = required | ||
| + | } | ||
| + | plz_ort { | ||
| + | errorCheck = required | ||
| + | } | ||
| + | land { | ||
| + | errorCheck = required | ||
| + | } | ||
| + | telefon { | ||
| + | errorCheck = required | ||
| + | } | ||
| + | mail { | ||
| + | errorCheck = email,required | ||
| + | } | ||
| + | kennzeichen { | ||
| + | errorCheck = required | ||
| + | } | ||
| + | hersteller { | ||
| + | errorCheck = required | ||
| + | } | ||
| + | fahrzeugnummer { | ||
| + | errorCheck = required | ||
| + | } | ||
| + | art { | ||
| + | errorCheck = required | ||
| + | } | ||
| + | antrieb { | ||
| + | errorCheck = required | ||
| + | } | ||
| + | gewicht { | ||
| + | errorCheck = required | ||
| + | } | ||
| + | ezul { | ||
| + | errorCheck = date:dd.mm.yyyy | ||
| + | errorCheck.dateRange.min = 01.01.1900 | ||
| + | errorCheck.dateRange.max = 31.12.2010 | ||
| + | } | ||
| + | fsvorne { | ||
| + | errorCheck = required | ||
| + | numberOfAllowedFiles = 1 | ||
| + | fileTypes = pdf,doc,jpg,gif,png | ||
| + | fileSize = 1500000 | ||
| + | fileUpload = fileadmin/plakette/uploads/ | ||
| + | errorText = <li>Das Feld Fahrzeugschein (Vorderseite) ist nicht korrekt ausgefüllt</li><br/> | ||
| + | uploadedFiles { | ||
| + | template = ###fileName### ###fileSize### <br /> | ||
| + | wrap = <div>Vorderseite: |</div> | ||
| + | } | ||
| + | uploadedFiles.mail { | ||
| + | plainTemplate = ###filePath### ###fileName### | ||
| + | HTMLTemplate = <a href="###filePath######fileName###">###fileName###</a><br/> | ||
| + | plainWrap = | | ||
| + | HTMLWrap = | | ||
| + | } | ||
| + | } | ||
| + | fshinten { | ||
| + | numberOfAllowedFiles = 1 | ||
| + | fileTypes = pdf,doc,jpg,gif,png | ||
| + | fileSize = 1500000 | ||
| + | fileUpload = fileadmin/plakette/uploads/ | ||
| + | errorText = <li>Das Feld Fahrzeugschein (Rückseite) ist nicht korrekt ausgefüllt</li><br/> | ||
| + | uploadedFiles { | ||
| + | template = ###fileName### ###fileSize### <br /> | ||
| + | wrap = <div>Rückseite: |</div> | ||
| + | } | ||
| + | uploadedFiles.mail { | ||
| + | plainTemplate = ###filePath######fileName### | ||
| + | HTMLTemplate = <a href="###filePath######fileName###">###fileName###</a><br/> | ||
| + | plainWrap = |file end | ||
| + | HTMLWrap = | | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | [PIDinRootline=305,307,309,311] | ||
| + | plugin.tx_thmailformplus_pi1.fieldConf.fsvorne{ | ||
| + | errorText = <li>Please complete the vehicle certification (front)</li><br/> | ||
| + | uploadedFiles { | ||
| + | template = ###fileName### ###fileSize### <br /> | ||
| + | wrap = <div>Front: |</div> | ||
| + | } | ||
| + | } | ||
| + | plugin.tx_thmailformplus_pi1.fieldConf.fshinten{ | ||
| + | errorText = <li>Please complete the vehicle certification (back)</li><br/> | ||
| + | uploadedFiles { | ||
| + | template = ###fileName### ###fileSize### <br /> | ||
| + | wrap = <div>Back: |</div> | ||
| + | } | ||
| + | } | ||
| + | |||
| + | |||
| + | [global] | ||
| + | </pre> | ||
| + | === Mails an Admin und Benutzer konfigurieren (Beispiel) === | ||
| + | |||
| + | <pre> | ||
| + | // Mails an Benutzer und Admin konfigurieren | ||
| + | // HINWEIS:Dies sind standard Werte. | ||
| + | // Kann im Plugin z.T überschrieben werden ! | ||
| + | |||
| + | plugin.tx_thmailformplus_pi1.default{ | ||
| + | // Adresse des Admin | ||
| + | email_to = webmaster@hfwu.de | ||
| + | // Betreff für Admin | ||
| + | email_subject = Anfrage über Alumni Kontaktformular | ||
| + | // Absender für Admin Mail | ||
| + | email_sender = web1@hfwu.de | ||
| + | // Dieses Feld des Formulars wird in "Antwort an" der E-Mail eingetragen | ||
| + | // Validierung nicht vergessen | ||
| + | email_replyto = email | ||
| + | |||
| + | // BENUTZER-EMAIL | ||
| + | // E-Mail Feld im Formularm, wenn der Benutzer eine E-Mail bekommen soll. | ||
| + | # email_sendtouser = email | ||
| + | // Betreff für Benutzer-Mail | ||
| + | # email_subject_user = Ihre Anfrage auf www.hfwu.de | ||
| + | } | ||
| + | </pre> | ||
| + | |||
| + | |||
| + | == Beispiele Mailformplus Formular Validierung == | ||
| + | plugin.tx_thmailformplus_pi1.fieldConf { | ||
| + | plz { | ||
| + | errorCheck = required | ||
| + | errorCheck.ereg = ^[0-9]{1,5}$ | ||
| + | } | ||
| + | } | ||
| + | |||
| + | === Mit Datenbank-Speicherung === | ||
| + | |||
| + | <pre> | ||
| + | ###################################### | ||
| + | # config for multipage forms | ||
| + | ###################################### | ||
| + | |||
| + | [PIDinRootline = 89] | ||
| + | plugin.tx_thmailformplus_pi1.multiPage.2.js ( | ||
| + | if((document.Formular.bremsassi1.checked==false) && (document.Formular.bremsassi2.checked==false) && (document.Formular.bremsassi3.checked==false)){ | ||
| + | alert('Emergency Brake Assistant - please select at least one of the checkboxes.'); | ||
| + | return false; | ||
| + | } | ||
| + | if((document.Formular.esp1.checked==false) && (document.Formular.esp2.checked==false) && (document.Formular.esp3.checked==false) && (document.Formular.esp4.checked==false)){ | ||
| + | alert('Electronic/Dynamic Stability Control/Program - please select at least one of the checkboxes.'); | ||
| + | return false; | ||
| + | } | ||
| + | if((document.Formular.spurassi1.checked==false) && (document.Formular.spurassi2.checked==false) && (document.Formular.spurassi3.checked==false)){ | ||
| + | alert('Lane departure warning/Lane keeping assistant - please select at least one of the checkboxes.'); | ||
| + | return false; | ||
| + | } | ||
| + | if((document.Formular.acc1.checked==false) && (document.Formular.acc2.checked==false) && (document.Formular.acc3.checked==false)){ | ||
| + | alert('Adaptive Cruise Control - please select at least one of the checkboxes.'); | ||
| + | return false; | ||
| + | } | ||
| + | if((document.Formular.nvs1.checked==false) && (document.Formular.nvs2.checked==false) && (document.Formular.nvs3.checked==false)){ | ||
| + | alert('Night Vision System - please select at least one of the checkboxes.'); | ||
| + | return false; | ||
| + | } | ||
| + | |||
| + | ) | ||
| + | [global] | ||
| + | |||
| + | ###################################### | ||
| + | # general configuration/setting | ||
| + | ###################################### | ||
| + | plugin.tx_thmailformplus_pi1 { | ||
| + | # limit the number of mails that | ||
| + | # are sent to the user | ||
| + | limitMailsToUser = 1 | ||
| + | # Debug Infos ausgeben | ||
| + | # saveDB.debug = 1 | ||
| + | } | ||
| + | |||
| + | ################################################### | ||
| + | ### storage table configuration & Standard-Werte ### | ||
| + | ################################################### | ||
| + | |||
| + | plugin.tx_thmailformplus_pi1{ | ||
| + | fieldConf.fahrleistungEinheit.defaultValue.value = km | ||
| + | fieldConf.datum.defaultValue.data = date : Y-m-d H:i:s | ||
| + | fieldConf.iphid.defaultValue.data = getenv : REMOTE_ADDR | ||
| + | |||
| + | #Speicherung in die Datenbank | ||
| + | saveDB = 1 | ||
| + | saveDB.dbkey=uid | ||
| + | saveDB.dbTable = tpUmfrage | ||
| + | saveDB.mapping = iphid:iphid,datum:datum,country:country,age:age,geschlecht:geschlecht,fahrpraxis:fahrpraxis,fahrleistungEinheit:fahrleistungEinheit,fahrleistung:fahrleistung,neuanschaffung:neuanschaffung,unfall:unfall,beruf:beruf,berufSonstiges:berufSonstiges,betrieb:betrieb,betriebSonstiges:betriebSonstiges,markengebunden:markengebunden,marke:marke,bremsassi1:bremsassi1,bremsassi2:bremsassi2,bremsassi3:bremsassi3,esp1:esp1,esp2:esp2,esp3:esp3,esp4:esp4,spurassi1:spurassi1,spurassi2:spurassi2,spurassi3:spurassi3,acc1:acc1,acc2:acc2,acc3:acc3,nvs1:nvs1,nvs2:nvs2,nvs3:nvs3,bremsassipraxis:bremsassipraxis,bremsassipot:bremsassipot,esppraxis:esppraxis,esppot:esppot,ahlpraxis:ahlpraxis,ahlpot:ahlpot,sideassipraxis:sideassipraxis,sideassipot:sideassipot,nvspraxis:nvspraxis,nvspot:nvspot,accpraxis:accpraxis,accpot:accpot,spurassipraxis:spurassipraxis,spurassipot:spurassipot,kunden01:kunden01,kunden02:kunden02,kunden03:kunden03,kunden04:kunden04,kunden05:kunden05,kunden06:kunden06,kunden07:kunden07,kunden08:kunden08,kunden09:kunden09,kunden10:kunden10,kunden11:kunden11,kunden12:kunden12,kunden13:kunden13,kunden14:kunden14,kunden15:kunden15,kunden16:kunden16,kunden17:kunden17,kunden18:kunden18,kunden19:kunden19,kunden20:kunden20,kunden21:kunden21,kunden22:kunden22,kunden23:kunden23,kunden24:kunden24,kunden25:kunden25,kunden26:kunden26,kunden27:kunden27,wissenbremsassi:wissenbremsassi,wissenesp:wissenesp,wissenahl:wissenahl,wissensideassi:wissensideassi,wissennvs:wissennvs,wissenacc:wissenacc,wissenspurassi:wissenspurassi,wissendcm:wissendcm,wissenpcs:wissenpcs,wissenisa:wissenisa,wissenrtti:wissenrtti,wissenaec:wissenaec,auffassung01:auffassung01,auffassung02:auffassung02,auffassung03:auffassung03,auffassung04:auffassung04,auffassung05:auffassung05,auffassung06:auffassung06,auffassung07:auffassung07,auffassung08:auffassung08,auffassung09:auffassung09,auffassung10:auffassung10,auffassung11:auffassung11,auffassung12:auffassung12,auffassung13:auffassung13,auffassung14:auffassung14,auffassung15:auffassung15,auffassung16:auffassung16,auffassung17:auffassung17,auffassung18:auffassung18,auffassung19:auffassung19,auffassung20:auffassung20,auffassung21:auffassung21,auffassung22:auffassung22,auffassung23:auffassung23,auffassung24:auffassung24,expeinsch01:expeinsch01,expeinsch02:expeinsch02,expeinsch03:expeinsch03,expeinsch04:expeinsch04,expeinsch05:expeinsch05,expeinsch06:expeinsch06,expeinsch07:expeinsch07,expeinsch08:expeinsch08,expeinsch09:expeinsch09,expeinsch10:expeinsch10,expeinsch11:expeinsch11,expeinsch12:expeinsch12,expeinsch13:expeinsch13,expeinsch14:expeinsch14,expeinsch15:expeinsch15,expeinsch16:expeinsch16,expeinsch17:expeinsch17,expeinsch18:expeinsch18,expeinsch19:expeinsch19,expeinsch20:expeinsch20,expeinsch21:expeinsch21,expeinsch22:expeinsch22,expeinsch23:expeinsch23,expeinsch24:expeinsch24,expeinsch25:expeinsch25,fortbildung:fortbildung,fortbildungSonstiges:fortbildungSonstiges,kommentar:kommentar | ||
| + | |||
| + | #für Checkboxen modifizierung der zu speichernden Felder ermöglichen | ||
| + | saveLog = 1 | ||
| + | #saveLog.order = bremsassi-1,bremsassi-2,bremsassi-3 | ||
| + | #saveLog.defaultValue = 0 | ||
| + | |||
| + | #folgende Felder nicht speichern... | ||
| + | #saveLog.exclude = alter | ||
| + | |||
| + | #saveDB.dbinsert=pid:546,hidden:0,CType:textpic | ||
| + | #saveUserFunc = fileadmin/template/benutzerfunktion/class.tx_mailformplus.php:tx_mailformplus->writeFormData | ||
| + | } | ||
| + | |||
| + | ###################################### | ||
| + | # here we overwrite the default configuration for | ||
| + | # file uploads defined in saveDB. for one | ||
| + | # specific field | ||
| + | ###################################### | ||
| + | plugin.tx_thmailformplus_pi1.fieldConf { | ||
| + | |||
| + | ###################### | ||
| + | # improved error check | ||
| + | # | ||
| + | # Info: | ||
| + | # error-check is performed for every field | ||
| + | # having a .errorCheck value defined here in TS | ||
| + | # | ||
| + | # works together with "required" fields settings | ||
| + | # from mailformplus record | ||
| + | # | ||
| + | # example: | ||
| + | # mailformplus record "required" field is filled out with "email" | ||
| + | # here in TS we have defined: | ||
| + | # email.errorCheck = email, optional | ||
| + | # so the value is optional - but if it's filled out, | ||
| + | # it's validated to be a correct email address | ||
| + | # | ||
| + | ###################### | ||
| + | # .errorCheck can be one of the following: | ||
| + | # | ||
| + | # - email ..... validated as email | ||
| + | # - integer ... validated as integer | ||
| + | # - float .... validated as float ("." and "," allowed!) | ||
| + | # - required ... must be filled out | ||
| + | # - optional ... field is optional, but if it's filled out, | ||
| + | # it's validated to the rest of errorChecks defined | ||
| + | # - date ... validated as date. format can/has to be specified | ||
| + | # example: | ||
| + | # errorCheck = date:dd/mm/yyyy | ||
| + | # errorCheck = date:d.m.y | ||
| + | # format is case insensitive. so dd/mm/yyyy is the same as DD/MM/YYYY | ||
| + | # | ||
| + | # - time ... validated as time. format can/has to be specified | ||
| + | # example: | ||
| + | # errorCheck = time:hh:mm | ||
| + | # errorCheck = time:h-m | ||
| + | # format is case insensitive. hh:mm equals HH:MM | ||
| + | # | ||
| + | # - ereg ... validated to match the regexp given | ||
| + | # example for correct IP validation: | ||
| + | # errorCheck = ereg:^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ | ||
| + | # | ||
| + | # - eregi ... like "ereg" but case insensitive | ||
| + | # | ||
| + | ###################### | ||
| + | # you can specify multiple errorchecks by separating them by "," | ||
| + | # example | ||
| + | # - errorCheck = required, email | ||
| + | ###################### | ||
| + | # .errorText ... text beeing displayed when error occurs | ||
| + | # Info: | ||
| + | # errorText overwrites the error-subtemplate value defined in the template | ||
| + | ####################### | ||
| + | |||
| + | # email { | ||
| + | # errorCheck = email,required | ||
| + | # errorText = <li>fill out a correct email</li><br> | ||
| + | # defaultValue.value = asdf | ||
| + | # } | ||
| + | |||
| + | fortbildung.errorCheck = required | ||
| + | fortbildung.errorText = | ||
| + | //.. | ||
| + | } | ||
| + | |||
| + | </pre> | ||
| + | |||
| + | == Probleme lösen == | ||
| + | === Es scheint alles zu funktionieren aber es kommt keine Mail an / Mailversand funktioniert nicht === | ||
| + | |||
| + | Im Error Log kommt die Meldung | ||
| + | ...sSMTP[28906]: 501 5.1.7 Bad sender address syntax... | ||
| + | |||
| + | '''Lösung''' | ||
| + | |||
| + | Die Sender Adresse wird abgewiesen, weil sie für das smtp Programm nicht gültig erscheint. Eine gültige Adresse hat die Form | ||
| + | meine@adresse.de | ||
| + | oder | ||
| + | meinName <meine@adresse.de> | ||
| + | |||
| + | In Mailformplus kann der Absender im Frontend Plugin in | ||
| + | Name des Absenders | ||
| + | gesetzt werden, oder in der Default Konfiguration (s.o.) Die Konfiguration im Plugin hat Vorang vor den Standardwerten im TypoScript. | ||
Aktuelle Version vom 12. März 2010, 14:05 Uhr
Datenbankspeicherung[Bearbeiten]
Kurzinfo[Bearbeiten]
1. Datenbanktabelle anlegen[Bearbeiten]
z.B. mit phpmyadmin
2. TypoScript[Bearbeiten]
plugin.tx_thmailformplus_pi1{
# DB
//einschalten
saveDB = 1
//Primärschlüssel
saveDB.dbkey=uid
//Tabellenname
saveDB.dbTable = myTable
// Speichere spezielle Werte (mehrerer mit Komma getrennt)
#saveDB.dbinsert = pid:546,hidden:0,CType:textpic
//Mapping => Formularfeld:DB-Feld - nur das wird gespeichert (+ spezial und dbinsert)
saveDB.mapping = studie:studie,anrede:anrede,vorname:vorname,name:name
// Spezielle Mapping Features
#saveDB.specialMapping = 1
#saveDB.specialMapping.sub_datetime = datum
#saveDB.specialMapping.logIP = ip
//folgende Felder nicht speichern...
#saveLog.exclude = alter
//für Checkboxen Modifizierung der zu speichernden Felder ermöglichen
//für Backend Export
#saveLog = 1
#saveLog.order =
#saveLog.defaultValue = 0
//Benutzerfunktion
#saveUserFunc = fileadmin/template/benutzerfunktion/class.tx_mailformplus.php:tx_mailformplus->writeFormData
}
Bereiche im HTML-Template[Bearbeiten]
Todo
Tipps und Tricks[Bearbeiten]
Mehrere Felder in ein Datenbankfeld[Bearbeiten]
saveDB.mapping = surname:name,forename:name
Post processing der Formularfelder[Bearbeiten]
Es gibt einen Hook den man nutzen kann um nach dem Erfolgreichen senden des Formulars die Daten an eigene PHP Skripte zu übergeben. (available since 3.7, thx to Martin Kutschker) Die Standard Funktionen wie Mails versenden oder Datensätze einfügen werden dadurch nicht beeinflusst.
So gehts:
- define a user-function which will do the processing
- create a php file with a class and function which will be called when the form was submitted:
example:
class.tx_myext.php
content:
class tx_myext {
function doit(&$params, &$ref){
......
}
}
Die Variable '$params enthält dann folgende Werte:
$params[config] Variablen die mit TypoScript übermittelt wurden. Z.B.:
saveUserFunc.dummy = hello
kann mit
$params[config][dummy]
angesprochen werden.
$params[data]
enthält alle übermittelten GET und POST Variablen
activate the hook with TypoScript[Bearbeiten]
Als erstes muß man die Funktion definieren die ausgeführt werden soll:
plugin.tx_thmailformplus_pi1.saveUserFunc = EXT:myext/class.tx_myext.php:tx_myext->doit
Man kann auch mit TS Variablen definieren die an das Skript übermittelt werden.
plugin.tx_thmailformplus_pi1.saveUserFunc.dummy = hello
Beispielkonfiguration (alt-brettheim.de)[Bearbeiten]
Version von Ende 2006
### mailformplus konfigurieren ###
#Checkbox 'Zustimmung zur Datenspeicherung' soll nicht in der DB gespeichert werden
plugin.tx_thmailformplus_pi1{
#email_redirect = 547
saveLog.exclude = datenspeicherung
#Speicherung in die Datenbank
saveDB = 1
saveDB.dbkey=uid
saveDB.dbTable = pupKarte
saveDB.fileUpload = fileadmin/pupKarte/
saveDB.fileTypes = jpg,jpeg,png,JPG,JPEG,PNG
saveDB.fileSize = 1000000
#Schlüsselfeld der DB-Tabelle
#Datenbank zuordnung
saveDB.mapping = photo:fileid,geb18:geb18,name:name,vorname:vorname,gebDatum:gebDatum,strasse:strasse,plz:plz,ort:ort,gruppe:gruppe,andereGruppe:andereGruppe,funktionGruppe:funktionGruppe,vabmitglied:vabmitglied,waffentraeger:waffentraeger,dekowaffe:dekowaffe,messer:messer,dolchEinseitig:dolchEinseitig,dolchZweiseitig:dolchZweiseitig,hiebwaffe:hiebwaffe,stichwaffe:stichwaffe,stangenwaffe:stangenwaffe,bogen:bogen,armbrust:armbrust,sonstigeWaffen:sonstigeWaffen,sprengstofferlaubnis:sprengstofferlaubnis,uneingeschraenkt:uneingeschraenkt,sonstigeWaffeArt:sonstigeWaffeArt,behoerde:behoerde,erlaubnisNr:erlaubnisNr,weitereGenehmigung:weitereGenehmigung,mitgliedSeit:mitgliedSeit,weitereVabMitgliedschaft:weitereVabMitgliedschaft,funktionen:funktionen,ehrungen:ehrungen,telefon:telefon,email:email,internWirdBezogen:internWirdBezogen,internErwuenscht:internErwuenscht,sonstiges:sonstiges
#nicht ausgefüllte Felder ausfüllen...
#saveDB.if_is_empty.dekowaffe = ka
#saveDB.debug = 1
Druckversion des Formulars[Bearbeiten]
1. Abschnitt für Printtemplate im mailformplus-HTML-Template:
Beispiel
<!-- ###TEMPLATE_PRINT### begin --> You just filled out the following fields:<br> Name: ###name###<br> Subject: ###subject###<br> <br> you uploaded the following files: ###photo### <br> ###cv### <br> <!-- ###TEMPLATE_PRINT### end -->
2. Eine Userfunktion zum speichern und übergeben der Session Variable
<?PHP
####################################
# example user-function for #
# fetching the PRINT-subtemplate #
####################################
class user_mailformplus_userfunc {
var $cObj;
# this function returns the "PRINT" subtemplate
# if defined in the mailformplus-template
# replaced with the values the user has filled out.
function user_mailformplusPrint($content,$conf) {
$printVersion = $GLOBALS["TSFE"]->fe_user->getKey("ses","th_mailformplus".$GLOBALS["TSFE"]->id);
if ($printVersion) {
return $printVersion;
}
}
}
?>
3. Das zugehörige TS Template
includeLibs.mailformplus_functions = fileadmin/mailformplus_userfunc.inc.php
################################
# outputs the PRINT template below normal page content
# main content
################################
temp.main_content = COA
temp.main_content {
10 < styles.content.get
20 = USER
20.userFunc = user_mailformplus_userfunc->user_mailformplusPrint
}
...
page.10.subparts.CONTENT_MAIN < temp.main_content
Verschiedene Beispiele[Bearbeiten]
JavaScript zur Validierung und Mailformplus[Bearbeiten]
plugin.tx_thmailformplus_pi1.multiPage.2.js (
if((document.Formular.bremsassi1.checked==false) && (document.Formular.bremsassi2.checked==false) && (document.Formular.bremsassi3.checked==false)){
alert('Bremsassistenten - wählen Sie bitte mindestens einen Punkt aus.');
return false;
}
if((document.Formular.esp1.checked==false) && (document.Formular.esp2.checked==false) && (document.Formular.esp3.checked==false) && (document.Formular.esp4.checked==false)){
alert('Elektronisches Stabilitätsprogramm - wählen Sie bitte mindestens einen Punkt aus.');
return false;
}
if((document.Formular.spurassi1.checked==false) && (document.Formular.spurassi2.checked==false) && (document.Formular.spurassi3.checked==false)){
alert('Spurassistent - wählen Sie bitte mindestens einen Punkt aus.');
return false;
}
if((document.Formular.acc1.checked==false) && (document.Formular.acc2.checked==false) && (document.Formular.acc3.checked==false)){
alert('Automatischer Abstandsregeltempomat - wählen Sie bitte mindestens einen Punkt aus.');
return false;
}
if((document.Formular.nvs1.checked==false) && (document.Formular.nvs2.checked==false) && (document.Formular.nvs3.checked==false)){
alert('Nachtsichtassistent - wählen Sie bitte mindestens einen Punkt aus.');
return false;
}
)
Beispiel mit verschiedenen Validierungen und Upload-Feld[Bearbeiten]
plugin.tx_thmailformplus_pi1{
#email_requiredfields = email,name
#email_attachment = ###fsvorne###
#email_sendtouser >
#debug = 1
}
plugin.tx_thmailformplus_pi1.fieldConf {
name {
errorCheck = required
}
strasse {
errorCheck = required
}
plz_ort {
errorCheck = required
}
land {
errorCheck = required
}
telefon {
errorCheck = required
}
mail {
errorCheck = email,required
}
kennzeichen {
errorCheck = required
}
hersteller {
errorCheck = required
}
fahrzeugnummer {
errorCheck = required
}
art {
errorCheck = required
}
antrieb {
errorCheck = required
}
gewicht {
errorCheck = required
}
ezul {
errorCheck = date:dd.mm.yyyy
errorCheck.dateRange.min = 01.01.1900
errorCheck.dateRange.max = 31.12.2010
}
fsvorne {
errorCheck = required
numberOfAllowedFiles = 1
fileTypes = pdf,doc,jpg,gif,png
fileSize = 1500000
fileUpload = fileadmin/plakette/uploads/
errorText = <li>Das Feld Fahrzeugschein (Vorderseite) ist nicht korrekt ausgefüllt</li><br/>
uploadedFiles {
template = ###fileName### ###fileSize### <br />
wrap = <div>Vorderseite: |</div>
}
uploadedFiles.mail {
plainTemplate = ###filePath### ###fileName###
HTMLTemplate = <a href="###filePath######fileName###">###fileName###</a><br/>
plainWrap = |
HTMLWrap = |
}
}
fshinten {
numberOfAllowedFiles = 1
fileTypes = pdf,doc,jpg,gif,png
fileSize = 1500000
fileUpload = fileadmin/plakette/uploads/
errorText = <li>Das Feld Fahrzeugschein (Rückseite) ist nicht korrekt ausgefüllt</li><br/>
uploadedFiles {
template = ###fileName### ###fileSize### <br />
wrap = <div>Rückseite: |</div>
}
uploadedFiles.mail {
plainTemplate = ###filePath######fileName###
HTMLTemplate = <a href="###filePath######fileName###">###fileName###</a><br/>
plainWrap = |file end
HTMLWrap = |
}
}
}
[PIDinRootline=305,307,309,311]
plugin.tx_thmailformplus_pi1.fieldConf.fsvorne{
errorText = <li>Please complete the vehicle certification (front)</li><br/>
uploadedFiles {
template = ###fileName### ###fileSize### <br />
wrap = <div>Front: |</div>
}
}
plugin.tx_thmailformplus_pi1.fieldConf.fshinten{
errorText = <li>Please complete the vehicle certification (back)</li><br/>
uploadedFiles {
template = ###fileName### ###fileSize### <br />
wrap = <div>Back: |</div>
}
}
[global]
Mails an Admin und Benutzer konfigurieren (Beispiel)[Bearbeiten]
// Mails an Benutzer und Admin konfigurieren
// HINWEIS:Dies sind standard Werte.
// Kann im Plugin z.T überschrieben werden !
plugin.tx_thmailformplus_pi1.default{
// Adresse des Admin
email_to = webmaster@hfwu.de
// Betreff für Admin
email_subject = Anfrage über Alumni Kontaktformular
// Absender für Admin Mail
email_sender = web1@hfwu.de
// Dieses Feld des Formulars wird in "Antwort an" der E-Mail eingetragen
// Validierung nicht vergessen
email_replyto = email
// BENUTZER-EMAIL
// E-Mail Feld im Formularm, wenn der Benutzer eine E-Mail bekommen soll.
# email_sendtouser = email
// Betreff für Benutzer-Mail
# email_subject_user = Ihre Anfrage auf www.hfwu.de
}
Beispiele Mailformplus Formular Validierung[Bearbeiten]
plugin.tx_thmailformplus_pi1.fieldConf {
plz {
errorCheck = required
errorCheck.ereg = ^[0-9]{1,5}$
}
}
Mit Datenbank-Speicherung[Bearbeiten]
######################################
# config for multipage forms
######################################
[PIDinRootline = 89]
plugin.tx_thmailformplus_pi1.multiPage.2.js (
if((document.Formular.bremsassi1.checked==false) && (document.Formular.bremsassi2.checked==false) && (document.Formular.bremsassi3.checked==false)){
alert('Emergency Brake Assistant - please select at least one of the checkboxes.');
return false;
}
if((document.Formular.esp1.checked==false) && (document.Formular.esp2.checked==false) && (document.Formular.esp3.checked==false) && (document.Formular.esp4.checked==false)){
alert('Electronic/Dynamic Stability Control/Program - please select at least one of the checkboxes.');
return false;
}
if((document.Formular.spurassi1.checked==false) && (document.Formular.spurassi2.checked==false) && (document.Formular.spurassi3.checked==false)){
alert('Lane departure warning/Lane keeping assistant - please select at least one of the checkboxes.');
return false;
}
if((document.Formular.acc1.checked==false) && (document.Formular.acc2.checked==false) && (document.Formular.acc3.checked==false)){
alert('Adaptive Cruise Control - please select at least one of the checkboxes.');
return false;
}
if((document.Formular.nvs1.checked==false) && (document.Formular.nvs2.checked==false) && (document.Formular.nvs3.checked==false)){
alert('Night Vision System - please select at least one of the checkboxes.');
return false;
}
)
[global]
######################################
# general configuration/setting
######################################
plugin.tx_thmailformplus_pi1 {
# limit the number of mails that
# are sent to the user
limitMailsToUser = 1
# Debug Infos ausgeben
# saveDB.debug = 1
}
###################################################
### storage table configuration & Standard-Werte ###
###################################################
plugin.tx_thmailformplus_pi1{
fieldConf.fahrleistungEinheit.defaultValue.value = km
fieldConf.datum.defaultValue.data = date : Y-m-d H:i:s
fieldConf.iphid.defaultValue.data = getenv : REMOTE_ADDR
#Speicherung in die Datenbank
saveDB = 1
saveDB.dbkey=uid
saveDB.dbTable = tpUmfrage
saveDB.mapping = iphid:iphid,datum:datum,country:country,age:age,geschlecht:geschlecht,fahrpraxis:fahrpraxis,fahrleistungEinheit:fahrleistungEinheit,fahrleistung:fahrleistung,neuanschaffung:neuanschaffung,unfall:unfall,beruf:beruf,berufSonstiges:berufSonstiges,betrieb:betrieb,betriebSonstiges:betriebSonstiges,markengebunden:markengebunden,marke:marke,bremsassi1:bremsassi1,bremsassi2:bremsassi2,bremsassi3:bremsassi3,esp1:esp1,esp2:esp2,esp3:esp3,esp4:esp4,spurassi1:spurassi1,spurassi2:spurassi2,spurassi3:spurassi3,acc1:acc1,acc2:acc2,acc3:acc3,nvs1:nvs1,nvs2:nvs2,nvs3:nvs3,bremsassipraxis:bremsassipraxis,bremsassipot:bremsassipot,esppraxis:esppraxis,esppot:esppot,ahlpraxis:ahlpraxis,ahlpot:ahlpot,sideassipraxis:sideassipraxis,sideassipot:sideassipot,nvspraxis:nvspraxis,nvspot:nvspot,accpraxis:accpraxis,accpot:accpot,spurassipraxis:spurassipraxis,spurassipot:spurassipot,kunden01:kunden01,kunden02:kunden02,kunden03:kunden03,kunden04:kunden04,kunden05:kunden05,kunden06:kunden06,kunden07:kunden07,kunden08:kunden08,kunden09:kunden09,kunden10:kunden10,kunden11:kunden11,kunden12:kunden12,kunden13:kunden13,kunden14:kunden14,kunden15:kunden15,kunden16:kunden16,kunden17:kunden17,kunden18:kunden18,kunden19:kunden19,kunden20:kunden20,kunden21:kunden21,kunden22:kunden22,kunden23:kunden23,kunden24:kunden24,kunden25:kunden25,kunden26:kunden26,kunden27:kunden27,wissenbremsassi:wissenbremsassi,wissenesp:wissenesp,wissenahl:wissenahl,wissensideassi:wissensideassi,wissennvs:wissennvs,wissenacc:wissenacc,wissenspurassi:wissenspurassi,wissendcm:wissendcm,wissenpcs:wissenpcs,wissenisa:wissenisa,wissenrtti:wissenrtti,wissenaec:wissenaec,auffassung01:auffassung01,auffassung02:auffassung02,auffassung03:auffassung03,auffassung04:auffassung04,auffassung05:auffassung05,auffassung06:auffassung06,auffassung07:auffassung07,auffassung08:auffassung08,auffassung09:auffassung09,auffassung10:auffassung10,auffassung11:auffassung11,auffassung12:auffassung12,auffassung13:auffassung13,auffassung14:auffassung14,auffassung15:auffassung15,auffassung16:auffassung16,auffassung17:auffassung17,auffassung18:auffassung18,auffassung19:auffassung19,auffassung20:auffassung20,auffassung21:auffassung21,auffassung22:auffassung22,auffassung23:auffassung23,auffassung24:auffassung24,expeinsch01:expeinsch01,expeinsch02:expeinsch02,expeinsch03:expeinsch03,expeinsch04:expeinsch04,expeinsch05:expeinsch05,expeinsch06:expeinsch06,expeinsch07:expeinsch07,expeinsch08:expeinsch08,expeinsch09:expeinsch09,expeinsch10:expeinsch10,expeinsch11:expeinsch11,expeinsch12:expeinsch12,expeinsch13:expeinsch13,expeinsch14:expeinsch14,expeinsch15:expeinsch15,expeinsch16:expeinsch16,expeinsch17:expeinsch17,expeinsch18:expeinsch18,expeinsch19:expeinsch19,expeinsch20:expeinsch20,expeinsch21:expeinsch21,expeinsch22:expeinsch22,expeinsch23:expeinsch23,expeinsch24:expeinsch24,expeinsch25:expeinsch25,fortbildung:fortbildung,fortbildungSonstiges:fortbildungSonstiges,kommentar:kommentar
#für Checkboxen modifizierung der zu speichernden Felder ermöglichen
saveLog = 1
#saveLog.order = bremsassi-1,bremsassi-2,bremsassi-3
#saveLog.defaultValue = 0
#folgende Felder nicht speichern...
#saveLog.exclude = alter
#saveDB.dbinsert=pid:546,hidden:0,CType:textpic
#saveUserFunc = fileadmin/template/benutzerfunktion/class.tx_mailformplus.php:tx_mailformplus->writeFormData
}
######################################
# here we overwrite the default configuration for
# file uploads defined in saveDB. for one
# specific field
######################################
plugin.tx_thmailformplus_pi1.fieldConf {
######################
# improved error check
#
# Info:
# error-check is performed for every field
# having a .errorCheck value defined here in TS
#
# works together with "required" fields settings
# from mailformplus record
#
# example:
# mailformplus record "required" field is filled out with "email"
# here in TS we have defined:
# email.errorCheck = email, optional
# so the value is optional - but if it's filled out,
# it's validated to be a correct email address
#
######################
# .errorCheck can be one of the following:
#
# - email ..... validated as email
# - integer ... validated as integer
# - float .... validated as float ("." and "," allowed!)
# - required ... must be filled out
# - optional ... field is optional, but if it's filled out,
# it's validated to the rest of errorChecks defined
# - date ... validated as date. format can/has to be specified
# example:
# errorCheck = date:dd/mm/yyyy
# errorCheck = date:d.m.y
# format is case insensitive. so dd/mm/yyyy is the same as DD/MM/YYYY
#
# - time ... validated as time. format can/has to be specified
# example:
# errorCheck = time:hh:mm
# errorCheck = time:h-m
# format is case insensitive. hh:mm equals HH:MM
#
# - ereg ... validated to match the regexp given
# example for correct IP validation:
# errorCheck = ereg:^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$
#
# - eregi ... like "ereg" but case insensitive
#
######################
# you can specify multiple errorchecks by separating them by ","
# example
# - errorCheck = required, email
######################
# .errorText ... text beeing displayed when error occurs
# Info:
# errorText overwrites the error-subtemplate value defined in the template
#######################
# email {
# errorCheck = email,required
# errorText = <li>fill out a correct email</li><br>
# defaultValue.value = asdf
# }
fortbildung.errorCheck = required
fortbildung.errorText =
//..
}
Probleme lösen[Bearbeiten]
Es scheint alles zu funktionieren aber es kommt keine Mail an / Mailversand funktioniert nicht[Bearbeiten]
Im Error Log kommt die Meldung
...sSMTP[28906]: 501 5.1.7 Bad sender address syntax...
Lösung
Die Sender Adresse wird abgewiesen, weil sie für das smtp Programm nicht gültig erscheint. Eine gültige Adresse hat die Form
meine@adresse.de
oder
meinName <meine@adresse.de>
In Mailformplus kann der Absender im Frontend Plugin in
Name des Absenders
gesetzt werden, oder in der Default Konfiguration (s.o.) Die Konfiguration im Plugin hat Vorang vor den Standardwerten im TypoScript.