Content objects (general information)¶
PHP information¶
The content objects (data type: cObject) are primarily controlled by the PHP-
script typo3/
.
The PHP-class is named Content
and often this is also
the variable-name of the objects ($c
).
The $cObj in PHP has an array, $this->data
, which holds records of
various kind. See data type "getText".
This record is normally "loaded" with the record from a table depending on the situation. Say if you are creating a menu it's often loaded with the page-record of the actual menu item or if it's about content-rendering it will be the content-record.
Reusing content objects¶
When dealing with "cObjects", you're allowed to use a special syntax in order to reuse cObjects without actually creating a copy. This has the advantage of minimizing the size of the cached template. But on the other hand it does not give you the flexibility of overriding values.
This example will show you how it works:
#
# Temporary objects are defined:
#
lib.stdheader = COA
lib.stdheader {
stdWrap.wrapAlign.field = header_position
stdWrap.typolink.parameter.field = header_link
stdWrap.fieldRequired = header
1 = TEXT
1.stdWrap.current = 1
stdWrap.space = {$content.headerSpace}
}
#
# CType: header
#
tt_content.header = COA
tt_content.header {
10 < lib.stdheader
10.stdWrap.space >
20 = TEXT
20.stdWrap.field = subheader
}
#
# CType: bullet
#
tt_content.bullets = COA
tt_content.bullets {
10 = < lib.stdheader
20 < styles.content.bulletlist_gr
}
First lib.
is defined. This is (and must be) a cObject! (In
this case it is COA.)
Now lib.
is copied to tt_
with the
"<
" operator. This means that an actual copy of lib.
is
created at parsetime.
But this is not the case with tt_
. Here
lib.
is referenced and lib.
will be used as the
cObject at runtime.
The reason why lib.stdheader was copied in the first case is the fact
that it's needed to unset ".stdWrap.space" inside the cObject
(10.
). This could not be done in the second case
where only a pointer is created.
Note:¶
If lib.
was temp.
instead, the pointer would
not work! This is due to the fact that the runtime-reference would
find nothing in temp.
as this is unset before the template is stored
in cache!
This goes for temp.
and styles.
(see the top-level object
definition elsewhere).
Overriding values anyway:
Although you cannot override values TypoScript-style (using the operators and all) the properties of the object which has the reference will be merged with the configuration of the reference.
Example:¶
page.10 = TEXT
page.10.value = kasper
page.10.stdWrap.case = upper
page.20 = < page.10
page.20.stdWrap.case = lower
page.20.value >
page.20.stdWrap.field = pages
The result is this configuration:
Notice that .value
was not cleared, because it's simply two arrays
which are joined:
So hence the line page.
in the above example is useless.