Zum Inhalt springen

Problem mit eigenem Template

Erstellt am 3. Juli 2007 · 3 Antworten · letzte Antwort am 6. Juli 2007

Tags: Frage

NickD ·

hallo,

ich habe ein template in meine extension eingebunden. dafür fülle ich erst eine klassenvariable mit den templatewerten:

function initialTemplateData()
{
    $this->templateCode              = $this->cObj->fileResource('fileadmin/templates/extensions/leasing2.htm');
    $this->template['list']          = $this->cObj->getSubpart($this->templateCode,'###TEMPLATE_LIST###');
    $this->template['list_item']     = $this->cObj->getSubpart($this->template['list'],'###LIST_ITEM###');
    $this->template['item_source']   = $this->cObj->getSubpart($this->templateCode,'###LIST_ITEM_SOURCE###');
}

das template sieht folgend aus:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Leasing</title>
</head>
<body>
<!-- ###TEMPLATE_LIST### begin -->
<div align="right">###CATEGORIE_SWITCHER###</div>

<table border="0" width="98%">
<!-- ###LIST_ITEM### begin-->

<tr bgcolor="#FF0000">
 <td></td>
</tr>
<tr bgcolor="#cbfecb">
 <td>
  <font size="3">
	 <b>
	  ###CATEGORIE_NAME###
	 </b>
	</font>
 </td>
</tr>
<tr bgcolor="#FF0000">
 <td></td>
</tr>

 ###LIST_ITEM_SOURCE### begin-->
<tr bgcolor="###BGCOLOR###">
 <td>
	###LINKTOSINGLE_BEGIN### ###ARTIKELTEXT### ###LINKTOSINGLE_END###
 </td>
</tr> 	
<!-- ###LIST_ITEM_SOURCE### end-->

<!-- ###LIST_ITEM### end-->
</table>
<!-- ###TEMPLATE_LIST### end -->
</body>
</html>

die list-ansicht behandel ich hier:

function showListData($kat_data)
	{
	  $GLOBALS['TSFE']->additionalHeaderData[$this->extKey] = '<link rel="stylesheet" type="text/css" href="fileadmin/templates/extensions/leasing2_list.css">';
	  $markerArray['###CATEGORIE_SWITCHER###'] = $this->getKategorieSwitcher($this->getAndPrepareCategories(true));

	  $color = "#eeeeee";
	   
    foreach($kat_data AS $key => $value)
    {
      $markerArray['###CATEGORIE_NAME###'] = $value;
      $content_item .= $this->cObj->substituteMarkerArrayCached($this->template['list_item'], $markerArray);
      
      $sql = 'SELECT * FROM tx_leasingmanager2_angebote WHERE kategorie = '.$key;
      $res = $GLOBALS['TYPO3_DB']->sql(TYPO3_db, $sql);
          
      while($row = mysql_fetch_array($res)) 
      {
        if($color == "#eeeeee")
         $markerArray['###BGCOLOR###'] = $color = '#ffffff';
          else
           $markerArray['###BGCOLOR###'] = $color = '#eeeeee';
        
         $markerArray['###LINKTOSINGLE_BEGIN###'] = '<a href="http://'.$_SERVER["HTTP_HOST"].'/typo3/index.php?id='.$GLOBALS['TSFE']->id.'&showDetail='.$row["uid"].'">';
         
         $markerArray['###ARTIKELTEXT###'] = $row["artikeltext"];
         
         $markerArray['###LINKTOSINGLE_END###'] = '</a>';
         $content_item .= $this->cObj->substituteMarkerArrayCached($this->template['item_source'], $markerArray);
         
      }  
      
      $subpartArray['###LIST_ITEM###'] = $content_item; 
    }

    return $this->cObj->substituteMarkerArrayCached($this->template['list'], $markerArray, $subpartArray);
  }

zu meinem problem:

obwohl die restlichen marker richtig gefüllt werden, sind noch 2 übeltäter in der listansicht: "###LIST_ITEM_SOURCE### begin--> ###LIST_ITEM_SOURCE### begin-->" und "###LINKTOSINGLE_BEGIN### ###ARTIKELTEXT### ###LINKTOSINGLE_END###".
die erste ausgabe taucht direkt unter der kategorieauswahl auf und die andere weiter unten. ich kann mir das nicht wirklich erklären, warum alle anderen gefüllt werden, nur diese beiden nicht.

hat jemand eine idee?

lg, nick

NickD ·

das eine problem habe ich bereits gefunden:

falsch: ###LIST_ITEM_SOURCE### begin-->
richtig: <!-- ###LIST_ITEM_SOURCE### begin-->

jetzt habe ich noch folgende marker drin:

###LINKTOSINGLE_BEGIN### ###ARTIKELTEXT### ###LINKTOSINGLE_END###

NickD ·

Ich habe es gelöst, bin aber auf das nächste Problem gestoßen: Der letzte Datensatz wird nun immer doppelt angezeigt. Was nun?