[Typo3-german] Ext Templating - Mehrere getSubpart in Extenion

Chi Hoang chibo at gmx.de
Wed Sep 7 13:18:06 CEST 2005


Andreas Kern schrieb:
> <!--###TEMPLATE_ALL###-->
> <table border="1" cellpadding="0" cellspacing="0">
>     <!--###TEMPLATE_ROW###-->
>         <tr>
>             <td><B>###MARKER_EINS###</B><br/>###MERKER_ZWEI###</td>
>         </tr>
>         <!--###TEMPLATE_ROW2###-->
>             <tr>
>                 <td>- ###UNTERMARKER_EINS###</td>
>             </tr>
>         <!--###TEMPLATE_ROW2###-->   
>     <!--###TEMPLATE_ROW###-->   
> </table>
> <!--###TEMPLATE_ALL###-->


Hallo Andreas,

verschachtelte subparts gehen glaube ich nicht. Wenn Du alternierende 
Zeilen brauchst habe ich das so gelöst:

     ###OUTPUTLIST###
     <!-- ###ROW1### -->
         <!-- ###LIST_ITEM1### -->
 
<tr><td><!--###LINK###-->###TITLE###<!--###LINK###--></td><td>###DESCRIPTION###</td><td>###PRICE###</td><td>###HISTORY###</td><td>###TIMELEFT###</td></tr>
         <!-- ###LIST_ITEM1### -->
     <!-- ###ROW1### -->
     <!-- ###ROW2### -->
         <!-- ###LIST_ITEM2### -->
             <tr 
bgcolor="#e0e0e0"><td><!--###LINK###-->###TITLE###<!--###LINK###--></td><td>###DESCRIPTION###</td><td>###PRICE###</td><td>###HISTORY###</td><td>###TIMELEFT###</td></tr>
         <!-- ###LIST_ITEM2### -->
     <!-- ###ROW2### -->

dann in php:

# Get the parts out of the template for viewing
             $template = array();
             $template["total"] = 
$this->cObj->getSubpart($this->templateCode,"###LIST###");
             $template["item1"] = 
$this->cObj->getSubpart($template["total"],"###LIST_ITEM1###");
             $template["item2"] = 
$this->cObj->getSubpart($template["total"],"###LIST_ITEM2###");


[...]

                 # Build content from template + array
                 if ($counter%2 == 0) {                    		
                     $content_item .= 
$this->cObj->substituteMarkerArrayCached($template["item1"], 
$markerArray, array(), $wrappedSubpartContentArray);
                 } else {
                     $content_item .= 
$this->cObj->substituteMarkerArrayCached($template["item2"], 
$markerArray, array(), $wrappedSubpartContentArray);
                 }
                 $counter+=1;

[...]


            # Create the whole table
             $subpartArray = array();
             $subpartArray["###ROW1###"] = '';
             $subpartArray["###ROW2###"] = '';
             $subpartArray["###OUTPUTLIST###"] = $content_item;

             $content = 
$this->cObj->substituteMarkerArrayCached($template["total"],$markerArray, 
$subpartArray, array());
             return $content;



Die rows werden einfach gelöscht, das komplette ergebnis mit 
alternierenden zeilen wird in ###OUTPUTLIST### abgelegt. So kann man 
auch beliebig viele alternierende Zeilen bauen oder auch Spalten, 
einfach den Zähler modulo anzahl spalten/zeilen nehmen.


Gruß,

Chi






More information about the TYPO3-german mailing list