[TYPO3-dev] meet a problem when using a HTML template‏

lm x xlmig at yahoo.com.cn
Mon Dec 15 10:52:13 CET 2008


Hello Everyone:

I'm just writing my first ext with a HTML template.  In the template there are two parts. The first part(###LISTVIEW###) has a form. when I submit the form, it shoud show me the second part(###DETAILVIEW###).

However it doesn't show the second part. and still show the first.  please Anyboby tell me what's wrong in my code. thank you!!!


the PHP part:

<?php

require_once(PATH_tslib.'class.tslib_pibase.php');

class tx_modulbuchtest_pi1 extends tslib_pibase {
    var $prefixId = 'tx_modulbuchtest_pi1';        // Same as class name
    var $scriptRelPath = 'pi1/class.tx_modulbuchtest_pi1.php';    // Path to this script relative to the extension dir.
    var $extKey = 'modulbuch_test';    // The extension key.
    var $pi_checkCHash = TRUE;

    function main($content,$conf)    {
        $this->conf=$conf;
        $this->pi_setPiVarDefaults();
        $this->pi_loadLL();
        
        #ein paar Vorbelegungen
        $this->id=$GLOBALS['TSFE']->id;
        $this->template=$this->cObj->fileResource('EXT:modulbuch_test/template.html');
        
        #welche Ansicht?
        if($this->piVars['item']) {
            $content = $this->detailView();
        } else {
            $content = $this->listView();
        }
    
        return $this->pi_wrapInBaseClass($content);
    }
    
    function listView() {
        $subpart=$this->cObj->getSubpart($this->template,'###LISTVIEW###'); 
        $singlerow=$this->cObj->getSubpart($subpart,'###ROW###'); 
        
        $markerArray['###ACTION_URI###'] = htmlspecialchars($this->pi_getPageLink($GLOBALS["TSFE"]->id));
    
        $res=$GLOBALS['TYPO3_DB']->exec_SELECTquery(
        '*',   #select
        'tx_modulbuchtest_module', #from 
        'hidden=0 and deleted=0 and pid='.$this->id,  #where
        $groupBy='',
        $orderBy='',
        $limit='');
        
        if($res) {
            $liste='';
            while($row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) 
            {
                $markerArray['###PROTYPE###']='<option value="456">'.$row['sprache'].'</option>';
                $liste .= $this->cObj->substituteMarkerArrayCached($singlerow,$markerArray); 
            }
            
            $subpartArray['###ROW###']=$liste;
        } else {
            return $this->pi_getLL('nodata');
        }
        
        return $this->cObj->substituteMarkerArrayCached($subpart,$markerArray,$subpartArray,'');  
    }
    
    
    
    function detailView() {
         $subpart=$this->cObj->getSubpart($this->template,'###DETAILVIEW###'); 
       
         $markerArray['###VORNAME###']='content for firstname';
            
        return $this->cObj->substituteMarkerArrayCached($subpart,$markerArray,'','');
    }
    
}  
 

if
(defined('TYPO3_MODE') &&
$TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/modulbuch_test/pi1/class.tx_modulbuchtest_pi1.php'])  
 {
    include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/modulbuch_test/pi1/class.tx_modulbuchtest_pi1.php']);
}

?>

the HTML template part :

<!-- ###LISTVIEW### -->
<h2>Search</h2>
<form action="###ACTION_URI###" id="form1" name="form1" method="post">
  <table width="478" border="1">
    <tr>
      <td width="114">&nbsp;</td>
      <td width="257"><div align="center">Search</div></td>
      <td width="85">&nbsp;</td>
    </tr>
    <tr>
      <td>Studiengang</td>
      <td><label>
        <input type="text" name="studiengang" id="studiengang" />
      </label></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>Pflicht oder Fwpf</td>
      <td><label>
        <select name="pflichtoderfwpf" id="pflichtoderfwpf">
        <!-- ###ROW### -->
          ###PROTYPE###
        <!-- ###ROW### -->
        </select>
      </label></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td><input type="submit" name="startsearch" id="startsearch" value="start search" /></td>
    </tr>
  </table>
  <p>&nbsp;</p>
</form>
<!-- ###LISTVIEW### -->


<!-- ###DETAILVIEW### -->
<h2>Detailansicht</h2>
<table valign=top border="1">
  <tr>
    <td>bookname</td>
    <td>|</td>
    <td>professor</td>
    <td>|</td>
    <td>püfung</td>
  </tr>
  <tr>
    <td colspan="7">----------------------------------</td></tr>
  <tr valign="top">
      <td align=top width="30"><p><b>###VORNAME###</b></p></td>
  </tr>
</table>
<!-- ###DETAILVIEW### -->


      ___________________________________________________________ 
  好玩贺卡等你发,邮箱贺卡全新上线! 
http://card.mail.cn.yahoo.com/



More information about the TYPO3-dev mailing list