Verdammt schöner Thread: ich das Problem auch.
Allerdings bin ich Newbie und von eurem Hin-und_her irritiert worden 😉
Vielleicht besteht ja die Möglichkeit, mir das für mein Konkretes Bsp zu erläutern -ich hab schwer versucht eure Aussagen zu verwerten, allerdings ohne Erfolg #angry#
....
require_once(PATH_tslib.'class.tslib_pibase.php');
class user_mtbspotguide_pi1 extends tslib_pibase {
var $prefixId = 'user_mtbspotguide_pi1'; // Same as class name
var $scriptRelPath = 'pi1/class.user_mtbspotguide_pi1.php'; // Path to this script relative to the extension dir.
var $extKey = 'user_mtb_spotguide'; // The extension key.
var $pi_checkCHash = TRUE;
var $stateCache = array();
var $kind_of_spotCache = array();
/**
* [Put your description here]
*/
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;
}
}
/**
* [Put your description here]
*/
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'] = 'user_mtbspotguide_spots';
$this->internal['currentRow'] = $this->pi_getRecord('user_mtbspotguide_spots',$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,5); // Number of results to show in a listing.
$this->internal['maxPages']=t3lib_div::intInRange($lConf['maxPages'],0,1000,1000);; // The maximum number of "pages" in the browse-box: "Page 1", "Page 2", etc.
$this->internal['searchFieldList']='city,state,kind_of_spot';
$this->internal['orderByList']='city,state,kind_of_spot';
// Get number of records:
$res = $this->pi_exec_query('user_mtbspotguide_spots',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('user_mtbspotguide_spots');
$this->internal['currentTable'] = 'user_mtbspotguide_spots';
// 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 search box:
$fullTable.=$this->pi_list_searchBox();
// Adds the whole list table
$fullTable.=$this->pi_list_makelist($res);
// Adds the result browser:
$fullTable.=$this->pi_list_browseresults();
// Returns the content from the plugin.
return $fullTable;
}
}
/**
* [Put your description here]
*/
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').'>
<h1>Details</h1>
<table>
<tr>
<td nowrap="" valign="top" this-="">pi_classParam('singleView-HCell').'><p><strong>'.$this->getFieldHeader('city').'</strong> </p></td>
<td valign="top"><p>'.$this->getFieldContent('city').'</p></td>
</tr>
<tr>
<td nowrap="" valign="top" this-="">pi_classParam('singleView-HCell').'><p><strong>'.$this->getFieldHeader('state').'</strong> </p></td>
<td valign="top"><p>'.$this->getFieldContent('state').'</p></td>
</tr>
<tr>
<td nowrap="" valign="top" this-="">pi_classParam('singleView-HCell').'><p><strong>'.$this->getFieldHeader('kind_of_spot').'</strong> </p></td>
<td valign="top"><p>'.$this->getFieldContent('kind_of_spot').'</p></td>
</tr>
<tr>
<td nowrap="" valign="top" this-="">pi_classParam('singleView-HCell').'><p><strong>'.$this->getFieldHeader('description').'</strong> </p></td>
<td valign="top"><p>'.$this->getFieldContent('description').'</p></td>
</tr>
<tr>
<td nowrap="" valign="top" this-="">pi_classParam('singleView-HCell').'><p><strong>'.$this->getFieldHeader('route').'</strong> </p></td>
<td valign="top"><p>'.$this->getFieldContent('route').'</p></td>
</tr>
<tr>
<td nowrap="" valign="top" this-="">pi_classParam('singleView-HCell').'><p><strong>'.$this->getFieldHeader('image').'</strong> </p></td>
<td valign="top"><p>'.$this->getFieldContent('image').'</p></td>
</tr>
<tr>
<td nowrap="" valign="top" this-="">pi_classParam('singleView-HCell').'><p><strong>'.$this->getFieldHeader('link_to_website').'</strong> </p></td>
<td valign="top"><p>'.$this->getFieldContent('link_to_website').'</p></td>
</tr>
</table>
<p>'.$this->pi_list_linkSingle($this->pi_getLL('back','Back'),0).'</p></div>'.
$this->pi_getEditPanel();
return $content;
}
/**
* [Put your description here]
*/
function pi_list_row($c) {
$editPanel = $this->pi_getEditPanel();
if ($editPanel) $editPanel='<td>'.$editPanel.'</td>';
return '<tr'.($c%2 this-="">pi_classParam('listrow-odd') : '').'>
<td valign="top"><p>'.$this->getFieldContent('city').' </p></td>
<td valign="top"><p>'.$this->getFieldContent('kind_of_spot').' </p></td>
<td valign="top"><p>'.$this->getFieldContent('state').' </p></td>
</tr>';
}
/**
* [Put your description here]
*/
function pi_list_header() {
return '<tr'.$this->pi_classParam('listrow-header').'>
<td><p>'.$this->getFieldHeader_sortLink('city').' </p><p></p></td>
<td><p>'.$this->getFieldHeader_sortLink('kind_of_spot').' </p><p></p></td>
<td><p>'.$this->getFieldHeader_sortLink('state').' </p><p></p></td>
</tr>';
}
/**
* [Put your description here]
*/
function getFieldContent($fN) {
switch($fN) {
case 'city':
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;
case 'state':
if (!count($this->stateCache)) {
$query = 'SELECT * FROM user_mtbspotguide_states WHERE pid='.intval($GLOBALS["TSFE"]->id).
$this->cObj->enableFields('user_mtbspotguide_states');
$res = mysql(TYPO3_db,$query);
while($row=mysql_fetch_assoc($res)) {
$this->stateCache[$row['uid']]=$row;
}
}
return htmlspecialchars($this->stateCache[$this->internal['currentRow']['state']]['state']);
break;
case 'kind_of_spot':
if (!count($this->kind_of_spotCache)) {
$query = 'SELECT * FROM user_mtbspotguide_kind_of_spot WHERE pid='.intval($GLOBALS["TSFE"]->id).
$this->cObj->enableFields('user_mtbspotguide_kind_of_spot');
$res = mysql(TYPO3_db,$query);
while($row=mysql_fetch_assoc($res)) {
$this->kind_of_spotCache[$row['uid']]=$row;
}
}
return htmlspecialchars($this->kind_of_spotCache[$this->internal['currentRow']['kind_of_spot']]['kind_of_spot']);
break;
default:
return $this->internal['currentRow'][$fN];
break;
}
}
/**
* [Put your description here]
*/
function getFieldHeader($fN) {
switch($fN) {
default:
return $this->pi_getLL('listFieldHeader_'.$fN,'['.$fN.']');
break;
}
}
/**
* [Put your description here]
*/
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/user_mtb_spotguide/pi1/class.user_mtbspotguide_pi1.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/user_mtb_spotguide/pi1/class.user_mtbspotguide_pi1.php']);
}
?>