---
title: "Auswahlliste"
url: "https://www.typo3.net/d/65032-auswahlliste"
source: "typo3.net"
tags: ["Extensions","Entwicklung","Frage","PHP","Templates & Layouts"]
created: "2007-07-09"
last_reply: "2007-07-17"
replies: 2
solved: false
page: 1
pages: 1
lang: "de"
---

# Auswahlliste

Extensions › Entwicklung · 2 Antworten · gestartet 2007-07-09

## Eröffnungsbeitrag

**saphir** · 2007-07-09 · [Beitrag #1](https://www.typo3.net/d/65032-auswahlliste/1)

Hallo, Leute,

ich habe eine Auswahlliste mit einem kleinen Problem.

HTML-Code für diese Auswahlliste:

```html
 <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:

```php
$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

## Antworten

### [#2](https://www.typo3.net/d/65032-auswahlliste/2) · mab82 · 2007-07-10

Du tust auch nur

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

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

### [#3](https://www.typo3.net/d/65032-auswahlliste/3) · saphir · 2007-07-17

jetzt funktioniert

```php
$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);
```

---

Quelle: „Auswahlliste“, typo3.net, https://www.typo3.net/d/65032-auswahlliste
Beiträge von Mitgliedern des Forums. Bitte mit Link auf die Diskussion zitieren.
