我正在尝试使用灵活的内容元素和 templavoila 将https://www.datatables.net/examples/data_sources/server_side.html实现到 Typo3(6.2LTS)中。结果是目前正在运行但为空(表中没有可用数据)表。我正在使用以下 php 脚本:
<?php
class custom_datatable {
var $datatable; // reference to the calling object.
function custom_table1($columns,$conf)
{
global $TSFE;
$TSFE->set_no_cache();
//do whatever you want here
//db verbindung
mysql_connect("my_host", "my_user", "my_password");
mysql_select_db("my_database");
/*
* DataTables example server-side processing script.
*
* Please note that this script is intentionally extremely simply to show how
* server-side processing can be implemented, and probably shouldn't be used as
* the basis for a large complex system. It is suitable for simple use cases as
* for learning.
*
* See http://datatables.net/usage/server-side for full details on the server-
* side processing requirements of DataTables.
*
* @license MIT - http://datatables.net/license_mit
*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Easy set variables
*/
// DB table to use
$table = 'my_table';
// Table's primary key
$primaryKey = 'id';
// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(
array( 'db' => 'Field1', 'dt' => 0 ),
array( 'db' => 'Field2', 'dt' => 1 ),
array( 'db' => 'Field3', 'dt' => 2 ),
array( 'db' => 'Field4', 'dt' => 3 ),
array( 'db' => 'Field5', 'dt' => 4 ),
array( 'db' => 'Field6', 'dt' => 5 )
);
return $columns;
}
}
?>
并在源代码中得到如下结果:
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Field1</th>
<th>Field2</th>
<th>Field3</th>
<th>Field4</th>
<th>Field5</th>
<th>Field6</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Field1</th>
<th>Field2</th>
<th>Field3</th>
<th>Field4</th>
<th>Field5</th>
<th>Field6</th>
</tr>
</tfoot>
</table>
<script type="text/javascript">
$(document).ready(function() {
$('#example').dataTable( {
"processing": true,
"serverSide": true,
"ajax": "Array"
} );
} );
</script>
我做错了什么或遗漏了什么?