class.tx_test_pi1.php
PHP код:
<?php
require_once(PATH_tslib.'class.tslib_pibase.php');
class tx_test_pi1 extends tslib_pibase {
var $prefixId = 'tx_test_pi1'; // Same as class name
var $scriptRelPath = 'pi1/class.tx_test_pi1.php'; // Path to this script relative to the extension dir.
var $extKey = 'test'; // The extension key.
var $pi_checkCHash = true;
var $order;
function main($content,$conf) {
$this->conf=$conf;
$this->pi_setPiVarDefaults();
$this->pi_loadLL();
$content = $this->displayList();
return $this->pi_wrapInBaseClass($content);
}
function displayList($content,$conf) {
if (isset($this->piVars['age'])) $this->order = 'age';
$this->templateCode = $this->cObj->fileResource('EXT:test/res/test_template.html');
$template = array();
$template['total'] = $this->cObj->getSubpart($this->templateCode,'###TEST_TEMPLATE###');
$template['singlerow'] = $this->cObj->getSubpart($template['total'],'###SINGLEROW###');
$template['row'] = $this->cObj->getSubpart($template['singlerow'],'###ITEM###');
$template['row_alt'] = $this->cObj->getSubpart($template['singlerow'],'###ITEM_ALT###');
$marker = array();
$marker['###TEST_HID###'] = $this->pi_getLL('id');
$marker['###TEST_HNAME###'] = $this->pi_getLL('name');
$marker['###TEST_HLNAME###']= $this->pi_getLL('lname');
$marker['###TEST_HAGE###'] = $this->pi_getLL('age');
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,name,last_name,age','tx_test_db','',$this->order);
$switch_row = 0;
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$marker['###TEST_ID###'] = $row['uid'];
$marker['###TEST_NAME###'] = $row['name'];
$marker['###TEST_LNAME###'] = $row['last_name'];
$marker['###TEST_AGE###'] = $row['age'];
$switch_row = $switch_row ^ 1;
if($switch_row) {
$content_item .= $this->cObj->substituteMarkerArrayCached($template['row'], $marker);
} else {
$content_item .= $this->cObj->substituteMarkerArrayCached($template['row_alt'], $marker);
}
}
$subpartArray['###SINGLEROW###'] = $content_item;
$content = $this->cObj->substituteMarkerArrayCached($template['total'],$marker,$subpartArray);
return $content;
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/test/pi1/class.tx_test_pi1.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/test/pi1/class.tx_test_pi1.php']);
}
?>
test_template.html
Код HTML:
<!-- ###TEST_TEMPLATE### begin -->
<table width=100% class="table">
<tr class="table-header">
<th>###TEST_HID###</th>
<th>###TEST_HNAME###</th>
<th>###TEST_HLNAME###</th>
<th>
<input type="submit" value="###TEST_HAGE###" class="tx-test-button" name="tx_test_pi1[age]" />
</th>
</tr>
<!-- ###SINGLEROW### -->
<!-- ###ITEM### -->
<tr class="table-body1">
<th>###TEST_ID###</th>
<th>###TEST_NAME###</th>
<th>###TEST_LNAME###</th>
<th>###TEST_AGE###</th>
</tr>
<!-- ###ITEM### -->
<!-- ###ITEM_ALT### -->
<tr class="table-body2">
<th>###TEST_ID###</th>
<th>###TEST_NAME###</th>
<th>###TEST_LNAME###</th>
<th>###TEST_AGE###</th>
</tr>
<!-- ###ITEM_ALT### -->
<!-- ###SINGLEROW### -->
<tr class="table-footer">
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</table>
<!-- ###TEST_TEMPLATE### end -->
надо, чтобы при нажатии на кнопку (
<input type="submit" value="###TEST_HAGE###" class="tx-test-button" name="tx_test_pi1[age]" />) сортировало таблицу по выбраному полю... чего-то не получается...
подскажите где не так плз...