[TYPO3-english] Datatables Serverside Processing in Typo3 (via Templavoila) / PHP issue
Jigal van Hemert
jigal.van.hemert at typo3.org
Mon Apr 13 14:09:12 CEST 2015
On 07/04/2015 10:35, Markus Philipp wrote:
> Hi Everyone,
>
> I'm struggling to implement Serverside Processing of Datatables into
> Typo3 6.2.9 (LTS). The data is rendered at the top of the browser and
> not in the table. I'm using the php/html as in the example provided by
> Datatables, please also see attached. I also included a link to the
> samples and to my example.
>
> I'm using Templavoila and the following marker:
>
> [globalVar = TSFE:id = 78]
> includeLibs.custom_datatable = fileadmin/templates/php/my.php
> lib.datatable = USER
> lib.datatable {
> userFunc = custom_datatable->custom_table1
> }
> [end]
>
> What am I missing or doing wrong?
The cause that it appears at the top of the browser is because in the
PHP script you output everything with echo json_encode(....); instead of
returning the content.
Another issue is that at the start of the script the entire frontend
caching is disabled. The result is that entire page content is generated
on each request. That is slow and it requires more processing on the
server. In TYPO3 you can make uncached plugins for that. If you use an
uncached plugin the rest of the page is cached; only the contents that
the plugin generates is rendered on each page request.
Furthermore the script uses direct database calls with its own code.
There is an easy $GLOBALS['TYPO3_DB'] object available with loads of
useful and easy functions.
Also, the PHP extension 'mysql' that the script uses is deprecated. Use
'mysqli' instead, or simply use the TYPO3_DB object (which uses mysqli
internally).
If you want to know more about pi_base programming, there is a nice book
by Dmitry Dulepov [1]. It was written before the core classes got
namespaces but in a decent IDE you can easily find the new names for the
old class names.
A small side note:
Attachments will show up for people who read your posts via the mailing
list or the newsgroups as blocks of base64 encoded data:
> begin 644 my_html.pdf
> M)5!$1BTQ+C0-)>+CS],-"C8@,"!O8FH-/#PO3&EN96%R:7IE9"`Q+TP@,34U
> M,S<O3R`X+T4@,3$S-#DO3B`Q+U0@,34S-S$O2"!;(#@Q-B`Q.#==/CX-96YD
[...]
It's easier if you put your files online somewhere and just provide a
link :-)
[1] https://www.packtpub.com/web-development/typo3-extension-development
--
Jigal van Hemert
TYPO3 CMS Active Contributor
TYPO3 .... inspiring people to share!
Get involved: typo3.org
More information about the TYPO3-english
mailing list