Hallo,
ich habe folghendes Problem...
Ich habe mir eine eigene Extension mit zwei Tabellen per Kickstarter (V 0.3.0.) erzeugt. Diese Ext hat ein BE Module und 3 FE Module
Das erste FE Modul (Pi1) soll als BSP die Tabelle 1 ausgeben,
Pi2 die Tabelle 2 und
Pi3 wurde ohne Beispielausgabe erzeugt.
Übergebe ich der Content-Variable irgendeinen Ausgabe-String, dann wird dieser ausgegeben.
Was nicht funktioniert sind die alle Datenbankabfragen, auch die in den Beispielen von pi1 und pi2.
Obwohl Daten in den beiden Extension Tabellen enthalten sind, gibt das vom Kickstarter erzeugte Beispiel keine Daten aus "Displaying results 0 to 0 out of 0".
Auch das Einfügen von eigenen MySQL Abfragen funktioniert nicht. Weiss jemand woran das liegen könnte?
Beispiel vom Kickstarter:
<?php
require_once(PATH_tslib.'class.tslib_pibase.php');
class tx_meineextension_pi1 extends tslib_pibase {
var $prefixId = 'tx_meineextension_pi1'; // Same as class name
var $scriptRelPath = 'pi1/class.tx_meineextension_pi1.php'; // Path to this script relative to the extension dir.
var $extKey = 'ah_meineextension'; // The extension key.
var $pi_checkCHash = TRUE;
/**
* Main method of your PlugIn
*
* @param string $content: The content of the PlugIn
* @param array $conf: The PlugIn Configuration
* @return The content that should be displayed on the website
*/
function main($content,$conf) {
switch((string)$conf['CMD']) {
case 'singleView':
list($t) = explode(':',$this->cObj->currentRecord);
$this->internal['currentTable']=$t;
$this->internal['currentRow']=$this->cObj->data;
return $this->pi_wrapInBaseClass($this->singleView($content,$conf));
break;
default:
if (strstr($this->cObj->currentRecord,'tt_content')) {
$conf['pidList'] = $this->cObj->data['pages'];
$conf['recursive'] = $this->cObj->data['recursive'];
}
return $this->pi_wrapInBaseClass($this->listView($content,$conf));
break;
}
}
/**
* Shows a list of database entries
*
* @param string $content: content of the PlugIn
* @param array $conf: PlugIn Configuration
* @return HTML list of table entries
*/
function listView($content,$conf) {
$this->conf=$conf; // Setting the TypoScript passed to this function in $this->conf
$this->pi_setPiVarDefaults();
$this->pi_loadLL(); // Loading the LOCAL_LANG values
$lConf = $this->conf['listView.']; // Local settings for the listView function
if ($this->piVars['showUid']) { // If a single element should be displayed:
$this->internal['currentTable'] = 'tx_meineextension_images';
$this->internal['currentRow'] = $this->pi_getRecord('tx_meineextension_images',$this->piVars['showUid']);
$content = $this->singleView($content,$conf);
return $content;
} else {
$items=array(
'1'=> $this->pi_getLL('list_mode_1','Mode 1'),
'2'=> $this->pi_getLL('list_mode_2','Mode 2'),
'3'=> $this->pi_getLL('list_mode_3','Mode 3'),
);
if (!isset($this->piVars['pointer'])) $this->piVars['pointer']=0;
if (!isset($this->piVars['mode'])) $this->piVars['mode']=1;
// Initializing the query parameters:
list($this->internal['orderBy'],$this->internal['descFlag']) = explode(':',$this->piVars['sort']);
$this->internal['results_at_a_time']=t3lib_div::intInRange($lConf['results_at_a_time'],0,1000,3); // Number of results to show in a listing.
$this->internal['maxPages']=t3lib_div::intInRange($lConf['maxPages'],0,1000,2);; // The maximum number of "pages" in the browse-box: "Page 1", "Page 2", etc.
$this->internal['searchFieldList']='artnr,text,preis';
$this->internal['orderByList']='uid,artnr,preis';
// Get number of records:
$res = $this->pi_exec_query('tx_meineextension_images',1);
list($this->internal['res_count']) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
// Make listing query, pass query to SQL database:
$res = $this->pi_exec_query('tx_meineextension_images');
$this->internal['currentTable'] = 'tx_meineextension_images';
// Put the whole list together:
$fullTable=''; // Clear var;
# $fullTable.=t3lib_div::view_array($this->piVars); // DEBUG: Output the content of $this->piVars for debug purposes. REMEMBER to comment out the IP-lock in the debug() function in t3lib/config_default.php if nothing happens when you un-comment this line!
// Adds the mode selector.
$fullTable.=$this->pi_list_modeSelector($items);
// Adds the whole list table
$fullTable.=$this->makelist($res);
// Adds the search box:
$fullTable.=$this->pi_list_searchBox();
// Adds the result browser:
$fullTable.=$this->pi_list_browseresults();
// Returns the content from the plugin.
return $fullTable;
}
}
/**
* Creates a list from a database query
*
* @param ressource $res: A database result ressource
* @return A HTML list if result items
*/
function makelist($res) {
$items=Array();
// Make list table rows
while($this->internal['currentRow'] = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$items[]=$this->makeListItem();
}
$out = '<div'.$this->pi_classParam('listrow').'>
'.implode(chr(10),$items).'
</div>';
return $out;
}
/**
* Implodes a single row from a database to a single line
*
* @return Imploded column values
*/
function makeListItem() {
$out='
<p'.$this->pi_classParam('listrowField-imgname').'>'.$this->getFieldContent('imgname').'</p>
<p'.$this->pi_classParam('listrowField-thumbname').'>'.$this->getFieldContent('thumbname').'</p>
<p'.$this->pi_classParam('listrowField-artnr').'>'.$this->getFieldContent('artnr').'</p>
<p'.$this->pi_classParam('listrowField-preis').'>'.$this->getFieldContent('preis').'</p>
<p'.$this->pi_classParam('listrowField-kat').'>'.$this->getFieldContent('kat').'</p>
<p'.$this->pi_classParam('listrowField-sort').'>'.$this->getFieldContent('sort').'</p>
';
return $out;
}
/**
* Display a single item from the database
*
* @param string $content: The PlugIn content
* @param array $conf: The PlugIn configuration
* @return HTML of a single database entry
*/
function singleView($content,$conf) {
$this->conf=$conf;
$this->pi_setPiVarDefaults();
$this->pi_loadLL();
// This sets the title of the page for use in indexed search results:
if ($this->internal['currentRow']['title']) $GLOBALS['TSFE']->indexedDocTitle=$this->internal['currentRow']['title'];
$content='<div'.$this->pi_classParam('singleView').'>
<H2>Record "'.$this->internal['currentRow']['uid'].'" from table "'.$this->internal['currentTable'].'":</H2>
<table>
<tr>
<td nowrap="nowrap" valign="top"'.$this->pi_classParam('singleView-HCell').'><p>'.$this->getFieldHeader('imgname').'</p></td>
<td valign="top"><p>'.$this->getFieldContent('imgname').'</p></td>
</tr>
<tr>
<td nowrap="nowrap" valign="top"'.$this->pi_classParam('singleView-HCell').'><p>'.$this->getFieldHeader('thumbname').'</p></td>
<td valign="top"><p>'.$this->getFieldContent('thumbname').'</p></td>
</tr>
<tr>
<td nowrap="nowrap" valign="top"'.$this->pi_classParam('singleView-HCell').'><p>'.$this->getFieldHeader('artnr').'</p></td>
<td valign="top"><p>'.$this->getFieldContent('artnr').'</p></td>
</tr>
<tr>
<td nowrap="nowrap" valign="top"'.$this->pi_classParam('singleView-HCell').'><p>'.$this->getFieldHeader('text').'</p></td>
<td valign="top"><p>'.$this->getFieldContent('text').'</p></td>
</tr>
<tr>
<td nowrap="nowrap" valign="top"'.$this->pi_classParam('singleView-HCell').'><p>'.$this->getFieldHeader('preis').'</p></td>
<td valign="top"><p>'.$this->getFieldContent('preis').'</p></td>
</tr>
<tr>
<td nowrap="nowrap" valign="top"'.$this->pi_classParam('singleView-HCell').'><p>'.$this->getFieldHeader('kat').'</p></td>
<td valign="top"><p>'.$this->getFieldContent('kat').'</p></td>
</tr>
<tr>
<td nowrap="nowrap" valign="top"'.$this->pi_classParam('singleView-HCell').'><p>'.$this->getFieldHeader('sort').'</p></td>
<td valign="top"><p>'.$this->getFieldContent('sort').'</p></td>
</tr>
<tr>
<td nowrap'.$this->pi_classParam('singleView-HCell').'><p>Last updated:</p></td>
<td valign="top"><p>'.date('d-m-Y H:i',$this->internal['currentRow']['tstamp']).'</p></td>
</tr>
<tr>
<td nowrap'.$this->pi_classParam('singleView-HCell').'><p>Created:</p></td>
<td valign="top"><p>'.date('d-m-Y H:i',$this->internal['currentRow']['crdate']).'</p></td>
</tr>
</table>
<p>'.$this->pi_list_linkSingle($this->pi_getLL('back','Back'),0).'</p></div>'.
$this->pi_getEditPanel();
return $content;
}
/**
* Returns the content of a given field
*
* @param string $fN: name of table field
* @return Value of the field
*/
function getFieldContent($fN) {
switch($fN) {
case 'uid':
return $this->pi_list_linkSingle($this->internal['currentRow'][$fN],$this->internal['currentRow']['uid'],1); // The "1" means that the display of single items is CACHED! Set to zero to disable caching.
break;
default:
return $this->internal['currentRow'][$fN];
break;
}
}
/**
* Returns the label for a fieldname from local language array
*
* @param [type] $fN: ...
* @return [type] ...
*/
function getFieldHeader($fN) {
switch($fN) {
default:
return $this->pi_getLL('listFieldHeader_'.$fN,'['.$fN.']');
break;
}
}
/**
* Returns a sorting link for a column header
*
* @param string $fN: Fieldname
* @return The fieldlabel wrapped in link that contains sorting vars
*/
function getFieldHeader_sortLink($fN) {
return $this->pi_linkTP_keepPIvars($this->getFieldHeader($fN),array('sort'=>$fN.':'.($this->internal['descFlag']?0:1)));
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/ah_productgallery/pi1/class.tx_meineextension_pi1.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/ah_productgallery/pi1/class.tx_meineextension_pi1.php']);
}
?>
Kickstarter ohne Beispiel mit eigenen MySQL versuchen (alle erfolglos )
<?php
require_once(PATH_tslib.'class.tslib_pibase.php');
class tx_ahmeineextension_pi3 extends tslib_pibase {
var $prefixId = 'tx_ahmeineextension_pi3'; // Same as class name
var $scriptRelPath = 'pi3/class.tx_ahmeineextension_pi3.php'; // Path to this script relative to the extension dir.
var $extKey = 'ah_meineextension'; // The extension key.
var $pi_checkCHash = TRUE;
function main($content,$conf) {
$this->conf=$conf;
$this->pi_setPiVarDefaults();
$this->pi_loadLL();
$this->pi_USER_INT_obj = 1;
$content = '';
$meineextensionPageID = $conf['meineextensionPageID'];
if(!intval($meineextensionPageID)) $meineextensionPageID=$GLOBALS["TSFE"]->id;
// Versuch 1
/* $query = $GLOBALS['TYPO3_DB']->SELECTquery(
'*', // SELECT ...
'tx_ahmeineextension_images, tx_ahmeineextension_kategory', // FROM ...
'TX_ahmeineextension_images.kat = TX_ahmeineextension_kategory.uid', // WHERE...
'', // GROUP BY...
'', // ORDER BY...
'' // LIMIT ...
);
$res = $GLOBALS['TYPO3_DB']->sql(TYPO3_db, $query);*/
// Versuch 2
//$query = 'SELECT * FROM tx_ahmeineextension_images';
//$res = mysql( TYPO3_db, $query );
// Versuch 3
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*',
'tx_ahmeineextension_images, tx_ahmeineextension_kategory',
'tx_ahmeineextension_images.pid="'.$meineextensionPageID.'"', '', '');
$content = '<table border=1>
<tr><th><b>'.
$TCA["TX_ahmeineextension_images.imgname"].'test</b></th><th><b>'.
$TCA["TX_ahmeineextension_images.thumbname"].'</b></th><th><b>'.
$TCA["TX_ahmeineextension_images.artnr"].'</b></th><th><b>'.
$TCA["TX_ahmeineextension_images.text"].'</b></th><th><b>'.
$TCA["TX_ahmeineextension_images.preis"].'</b></th><th><b>'.
$TCA["TX_ahmeineextension_images.kat"].'</b></th><th><b>'.
$TCA["TX_ahmeineextension_images.sort"].'</b></th><th><b>'.
$TCA["TX_ahmeineextension_kategory.katnr"].'</b></th><th><b>'.
$TCA["TX_ahmeineextension_kategory.katname"].'</b></th>
</tr>';
while ($row = $GLOBALS["TYPO3_DB"]->sql_fetch_assoc($res)) {
$content .= '<tr><td>'.
$row["TX_ahmeineextension_images.imgname"].'</td><td>'.
$row["TX_ahmeineextension_images.tdumbname"].'</td><td>'.
$row["TX_ahmeineextension_images.artnr"].'</td><td>'.
$row["TX_ahmeineextension_images.text"].'</td><td>'.
$row["TX_ahmeineextension_images.preis"].'</td><td>'.
$row["TX_ahmeineextension_images.kat"].'</td><td>'.
$row["TX_ahmeineextension_images.sort"].'</td><td>'.
$row["TX_ahmeineextension_kategory.katnr"].'</td><td>'.
$row["TX_ahmeineextension_kategory.katname"].'</td></tr>';
}
$content .= '</table>';
//$content = '';
//$content = 'Test: '.$res;
//$content = 'Test der Ausgabe';
//debug($content, 'Ich bin der Inhalt von $content');
//return $this->pi_wrapInBaseClass($content);
return $content;
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/ah_meineextension/pi3/class.tx_ahmeineextension_pi3.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/ah_meineextension/pi3/class.tx_ahmeineextension_pi3.php']);
}
?>
ich weiss einfach nicht, wo das Problem liegt. Hat jemand eine Idee?
Vielen Dank schonmal
Gruß Flippynorra
*** EDIT: zweiten Codeabschnitt aktuallisiert ****