[TYPO3-dev] Possible RFC : Introducing LOOP cObject
Xavier Perseguers
typo3 at perseguers.ch
Mon Jan 31 15:51:19 CET 2011
Hi again,
Here is a complete example of use (as seen in the BT):
in pi1/class.tx_yourext_pi1.php, method main():
$myData = array();
$myData[] = array('lastname' => 'Hader', 'firstname' => 'Oliver');
$myData[] = array('lastname' => 'Kamper', 'firstname' => 'Steffen');
$myData[] = array('lastname' => 'Baschny', 'firstname' => 'Ernesto');
$myData[] = array('lastname' => 'Perseguers', 'firstname' => 'Xavier');
$this->cObj->start($myData);
return $this->cObj->cObjGetSingle(
$this->conf['persons'],
$this->conf['persons.']
);
in res/template.html:
<html>
<head>
<title></title>
</head>
<body>
<!-- ###PERSONS### [begin] -->
<table>
<thead>
<tr>
<th>###HEADER_FIRSTNAME###</th>
<th>###HEADER_LASTNAME###</th>
</tr>
</thead>
<tbody>
<!-- ###PERSON### [begin] -->
<tr>
<td>###FIRSTNAME###</td>
<td>###LASTNAME###</td>
</tr>
<!-- ###PERSON### [end] -->
</tbody>
</table>
<!-- ###PERSONS### [end] -->
</body>
</html>
TypoScript:
plugin.tx_yourext_pi1.persons = TEMPLATE
plugin.tx_yourext_pi1.persons {
template = FILE
template.file = EXT:your_ext/res/template.html
workOnSubpart = PERSONS
marks {
HEADER_FIRSTNAME = TEXT
HEADER_FIRSTNAME.value = First Name
HEADER_LASTNAME = TEXT
HEADER_LASTNAME.value = Last Name
}
subparts.PERSON = LOOP
subparts.PERSON.renderObj = TEMPLATE
subparts.PERSON.renderObj.template < .template
subparts.PERSON.renderObj {
workOnSubpart = PERSON
marks {
FIRSTNAME = TEXT
FIRSTNAME.field = firstname
LASTNAME = TEXT
LASTNAME.field = lastname
}
}
}
More information about the TYPO3-dev
mailing list