Einzelnen Beitrag anzeigen
  #10  
Alt 29.08.08, 01:21
volcanodiscovery volcanodiscovery ist offline
Forum Zuschauer
 
Registriert seit: 27.08.08
Beiträge: 7

Entschuldigt, dass ich mit dem online Editor zum Formatieren von Einträgen in diesem Forum nicht umgehen kann und den Code unten nicht besser lesbar darstellen kann... Vielleicht brauche ich nen Crash-Kurs hier...

So, aber hier nun doch noch das fertige Produkt, falls mal jemand auf ein ähnliches Problem stößt. Dank Eurer Hilfe, Alex' tollem Support und dieser großartigen Extension ist unser Formular nun um einiges leichter zu pflegen (und netter anzuschauen) als vorher mit mailformplus...:

Ergebnis zuerst:

HTML-Code:
http://www.volcanodiscovery.com/volcano-tours/reisebuchung.html?&tx_tdtour_pi1[tourdateUid]=122&tx_tdtour_pi1[showUid]=76&cHash=ce5dc7674a
der Link dazu


- Es werden hier vom plugin, das die Touren darstellt (tx_tdtour_pi1) 2 Parameter mitübergeben, die sagen, welche Tour gewählt ist und davon welche Variante.

- Die ersten 3 Felder (Name des Programms und die beiden Auswahlboxen darunter werden von USER Funktionen gemacht:

1. TS setup für das Feld:

tourversion = USER
tourversion {
userFunc = user_tdtour->getVersionOptions
fieldUid = 265
fieldUid.lang.de = 277
label = Select tour version
label.lang.de = Version
}

2. Die aufgerufene Funktion sieht dann so aus:


PHP-Code:
function getVersionOptions($content,$conf) {
// uid and label of field (manually given via TS powermail)
$fieldUid $this->cObj->stdWrap($conf['fieldUid'],$conf['fieldUid.']);
$label $this->cObj->stdWrap($conf['label'],$conf['label.']);
 
// Get/Post vars from calling plugin 
$GP t3lib_div::GPvar('tx_tdtour_pi1');
 
// session data for this form
$PMsessionData $GLOBALS['TSFE']->fe_user->getKey('ses','powermail_'.$this->cObj->data['uid']);
 
// these are the table and field where the options come from (these params can be given through conf, to make it more general)  
$table 'tx_tdtour_itineraries';
$field 'title';
 
// this method (can be replaced dep. on context) actually gets me the valid UIDs from $table (versions) where the options come from
$versions $this->getVersionsFromProgram($GP['showUid']);
 
// loop through the items and construct options 
foreach ($versions as $versionUid) {
// select DB record
$res $GLOBALS['TYPO3_DB']->exec_SELECTquery('*',$table,'uid='.$versionUid.$this->cObj->enableFields($table).' AND (sys_language_uid=0 OR sys_language_uid=-1)');
$row $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
//language overlay
$row $GLOBALS['TSFE']->sys_page->getRecordOverlay($table,$row,$GLOBALS['TSFE']->sys_language_uid);
if (!
$row) continue;
 
 
/* Kommentar zur Einstellung des vorselektieren Werts
->check 1. if value is already in sesssion; 2. if not, perhaps it is given through Get/Post from calling plugin
if we want the uid as values, use these 3 lines instead of the next ones (but then, we need to re-translate this in the confirmation page and emails, to make a readable output
 
$selected = ($versionUid === $PMsessionData['uid'.$fieldUid]) ? ' selected="selected"' : '';
if (!$selected) $selected = ($row['uid'] == $GP['versionUid']) ? ' selected="selected"' : '';
$options .= '<option value="'.$versionUid.'"'.$selected.'>'.$row[$field].'</option>';
*/
 
// we go the way that the value equals the displayed option (label), as PM does naturally
$selected = ($row[$field] === $PMsessionData['uid'.$fieldUid]) ? ' selected="selected"' '';
if (!
$selected$selected = ($row['uid'] == $GP['versionUid']) ? ' selected="selected"' '';
$options .= '<option value="'.$row[$field].'"'.$selected.'>'.$row[$field].'</option>';
$count++;
}
 
// wrap select around options (if any were found), or return placeholder
if (!$options) return $this->cObj->cObjGetSingle($conf['emptyItem'],$conf['emptyItem.']);
else 
$select '<select name="tx_powermail_pi1[uid'.$fieldUid.']" class="powermail_select powermail_uid'.$fieldUid.'" id="uid'.$fieldUid.'">'.$options.'</select>';
 
// add div label around the select field
$content '<div class="tx_powermail_pi1_fieldwrap_html tx_powermail_pi1_fieldwrap_html_text tx_powermail_pi1_fieldwrap_html_'.$fieldUid.'">';
$content .= '<label for="uid'.$fieldUid.'">'.$label.'</label>';
$content .= $select.'</div>';
return 
$content;


3. das Feld im Plugin vom Typ TS-Object lautet dann:
plugin.tx_powermail_pi1.dynamicTyposcript.tourversion
...


Viele Grüße,

Tom
PS: 10% Rabatt auf Buchungen wenn Ihr von hier da obenreinkommt...;-)

Geändert von volcanodiscovery (29.08.08 um 02:01 Uhr).
Mit Zitat antworten