[FEATURE] Add Data Processor for fetching DB records
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Documentation / Changelog / master / Feature-68094-DatabaseQueryDataProcessor.rst
1 ==============================================
2 Feature: #68094 - Database Query DataProcessor
3 ==============================================
4
5 Description
6 ===========
7
8 A new Database Query DataProcessor has been introduced, which can be used to fetch data from the Database
9 to be handled by a ContentObject implementing the processors, e.g. the FLUIDTEMPLATE ContentObject.
10
11 The Database Query Processor works like the code from the Content Object CONTENT, except for just handing
12 over the result as array. A FLUIDTEMPLATE can then simply iterate over processed data automatically.
13
14 .. code-block:: typoscript
15
16 tt_content.mycontent.20 = FLUIDTEMPLATE
17 tt_content.mycontent.20 {
18 file = EXT:myextension/Resources/Private/Templates/ContentObjects/MyContent.html
19
20 dataProcessing.10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
21 dataProcessing.10 {
22 # regular if syntax
23 if.isTrue.field = records
24
25 # the table name from which the data is fetched from
26 # + stdWrap
27 table = tt_address
28
29 # All properties from .select can be used directly
30 # + stdWrap
31 colPos = 1
32 pidInList = 13,14
33
34 # The target variable to be handed to the ContentObject again, can be used
35 # in Fluid e.g. to iterate over the objects. defaults to "records" when not defined
36 # + stdWrap
37 as = myrecords
38
39 # The fetched records can also be processed by DataProcessors.
40 # All configured processors are applied to every row of the result.
41 dataProcessing {
42 10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
43 10 {
44 references.fieldName = image
45 }
46 }
47 }
48 }
49
50 In the Fluid template then iterate over the files:
51
52 .. code-block:: html
53
54 <ul>
55 <f:for each="{myrecords}" as="record">
56 <li>
57 <f:image image="{record.files.0}" />
58 <a href="{record.data.www}">{record.data.first_name} {record.data.last_name}</a>
59 </li>
60 </f:for>
61 </ul>