Mailformplus (tx mailformplus): Unterschied zwischen den Versionen

Aus Wikizone
Wechseln zu: Navigation, Suche
Zeile 65: Zeile 65:
  
 
=== Druckversion des Formulars ===
 
=== Druckversion des Formulars ===
1. Abschnitt für Printtemplate im mailformplus-HTML-Template:
+
'''1. Abschnitt für Printtemplate im mailformplus-HTML-Template:'''
  
Beispiel
+
'''Beispiel'''
 
<pre>
 
<pre>
 
<!-- ###TEMPLATE_PRINT### begin -->
 
<!-- ###TEMPLATE_PRINT### begin -->
Zeile 82: Zeile 82:
 
</pre>
 
</pre>
  
2. Eine Userfunktion zum speichern und übergeben der Session Variable
+
'''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>

Version vom 3. April 2007, 16:08 Uhr

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. (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

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)

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

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