Zum Inhalt springen

Auswahlliste

Erstellt am 9. Juli 2007 · 2 Antworten · letzte Antwort am 17. Juli 2007

Tags: Frage

saphir ·

Hallo, Leute,

ich habe eine Auswahlliste mit einem kleinen Problem.

HTML-Code für diese Auswahlliste:

 <body>
 <!--###TEMPLATE_BRANCHEN###-->
 <table border="0" align="center">
  <tr>
 <td>                 
 <form action="###ACTION_URI###" method="POST">
 <select name="###PREFIXID###[select]">                  
 <option>- wählen Sie die Branche aus...</option>
 <!--###TEMPLATE_BR###-->
  <option value="###UID###">###BRANCHE###</option>
  <!--###TEMPLATE_BR###-->
  </select>
 </form> 
  </td>
  </tr>
 </table>
 <!--###TEMPLATE_BRANCHEN###-->
 </body>

PHP-Code für diese Auswahlliste:

$markerArray = array();
$subPartArray = array();
$wrapArray = array();               
        
$templateFile = 'EXT:user_branchen/res/branchen.html';
$templateMarker = '###TEMPLATE_BRANCHEN###';
$markerArray['###ACTION_URI###'] = htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI'));
$markerArray['###PREFIXID###'] = $this->prefixId;
$templateCode = $this->cObj->fileResource($templateFile);
$templateCode = $this->cObj->getSubpart($templateCode, $templateMarker);
$templateBr = $this->cObj->getSubpart($templateCode, "###TEMPLATE_BR###");
$res = $GLOBALS['TYPO3_DB'] ->exec_SELECTquery('*', 'user_branchen_branche', 'pid = 3');
 
if (mysql_error()) debug (array(mysql_error(), $query));  
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res ))  
{
  $id = $row['uid'];
  $branche = $row['branche'];
                                    
  $markerArray['###BRANCHE###'] = $branche;
  $markerArray['###UID###'] = $id;
 
  $content .= $this->cObj->substituteMarkerArrayCached($templateBr, $markerArray); 
} 
 
 // Replace the remaining markers
 $content = $this->cObj->substituteSubpart (templateCode, '###TEMPLATE_BR###', $content);
                        
return $this->pi_wrapInBaseClass($content);

Alle Datensätze werden in der Auswahlliste korrekt angezeigt. Das Problem liegt an zwei Marker: ###ACTION_URI### und ###PREFIXID### Sie werden nicht ersetzt.

Nach dem Ausführen sieht der Quelltext so aus:

<!--

BEGIN: Content of extension "user_branchen", plugin "user_branchen_pi1"

-->
<div class="user-branchen-pi1">

<table border="0" align="center">
<tr>
<td>
<form action="###ACTION_URI###" method="POST">
<select name="###PREFIXID###[select]">
<option>- wählen Sie die Branche aus...</option>

<option value="1">Auto, Transport, Verkehr</option>

<option value="2">Bildung</option>

<option value="4">Dienstleistungen</option>

<option value="10">Handwerk</option>

<option value="3">Computer, Elektronik, Büro</option>

<option value="5">Essen und Trinken</option>

<option value="6">Finanzen, Versicherung, Recht</option>

<option value="7">Freizeit und Kultur</option>

<option value="8">Gesundheit und Lebenshilfe</option>

<option value="9">Handel, Gewerbe, Industrie</option>

<option value="11">Hotels und Reisen</option>

<option value="12">Medien, Design, Werbung</option>

<option value="13">Mode und Beauty</option>

<option value="14">Sport und Fitness</option>

<option value="15">Wohnen, Immobilien, Bauen</option>

<option value="16">Verbände, Vereine, Organisationen</option>

</select>
</form>
</td>
</tr>
</table>

</div>

<!-- END: Content of extension "user_branchen", plugin "user_branchen_pi1" -->

Was mache ich falsch? Ich bedanke mich im Voraus für die Hilfe

Mit freundlichen Grüßen
Natascha, Frankfurt am Main

mab82 ·

Du tust auch nur

$content = $this->cObj->substituteSubpart (templateCode, '###TEMPLATE_BR###', $content);

wrappen. Deshalb ersetzt er auch nur diese Marker die innerhalb dieses Subparts sind.

saphir ·

jetzt funktioniert

$markerArray = array();
$subPartArray = array();
$wrapArray = array();		
        
$templateFile = 'EXT:user_branchen/res/branchen.html';
$templateMarker = '###TEMPLATE_BRANCHEN###';
$markerArray['###ACTION_URI###'] = htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI'));
$markerArray['###PREFIXID###'] = $this->prefixId;
$templateCode = $this->cObj->fileResource($templateFile);
$templateCode = $this->cObj->getSubpart($templateCode, $templateMarker);
$templateBr = $this->cObj->getSubpart($templateCode, "###TEMPLATE_BR###");
$res = $GLOBALS['TYPO3_DB'] ->exec_SELECTquery ('*', 'user_branchen_branche', 'pid = 3');

if (mysql_error()) debug (array(mysql_error(), $query));  
     	while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res ))  
     	{
     	$id = $row['uid'];
	$branche = $row['branche'];			 
	$markerArray2['###BRANCHE###'] = $branche;
	$markerArray2['###UID###'] = $id;

	$content_br .= $this->cObj->substituteMarkerArrayCached($templateBr, $markerArray2); 
  	} 

// Replace the remaining markers
$subPartArray['###TEMPLATE_BR###'] = $content_br;		
$content = $this->cObj->substituteMarkerArrayCached($templateCode, $markerArray, $subPartArray, array());
return $this->pi_wrapInBaseClass($content);