Appendix A – PHP include scripts¶
Including your script¶
This section should give you some pointers on what you can process in your script and which functions and variables you can access.
Your script is included inside the class "ContentObjectRenderer" in the
script. Thereby your file is a part of this object
(ContentObjectRenderer). This is why you must return all
content in the variable "$content" and any TypoScript configuration is
available from the array "$conf" (it may not be set at all though, so
check it with is_array()!)
Contains the content, which was passed to the object, if any. All content, which you want to return, must be in this variable!
Remember, don't output anything (but debug code) directly in your script!
The array $conf contains the configuration for the USER cObject. Try debug($conf) to see the content printed out for debugging!
Because nothing is sent off to the browser before everything is
rendered and returned to
(which originally set off the rendering process), you must ensure
that there's no whitespace before and after your <?php...?> tags
in your include or library scripts!
Call the function
$GLOBALS['TSFE']->set_no_cache(), if you want to
disable caching of the page. Call this during development only! And
call it, if the content you create may not be cached.
Note: If you make a syntax error in your script that keeps PHP
from executing it, then the
function is not executed and the page is cached! So in these
situations, correct the error, clear the page-cache and try again.
This is true only for
USER and not for
USER_INT, which is
rendered after the cached page!
$this->cObjGetSingle(value, properties[, TSkey = '__'])¶
Gets a content object from the $conf array. $TSkey is an optional string label used for the internal debugging tracking.
$content = $this->cObjGetSingle($conf['image'], $conf['image.'], 'My Image 2');
This would return any IMAGE cObject at the property "image" of the $conf array for the include script!
Hands the content in "value" to the stdWrap function, which will process it according to the configuration of the array "properties".
$content = $this->stdWrap($content, $conf['stdWrap.']);
This will stdWrap the content with the properties of ".stdWrap" of the $conf array!
Internal variables in the main frontend object, TSFE¶
There are some variables in the global object, TSFE (TypoScript
Frontend), you might need to know about. These ARE ALL READ-ONLY!
(Read: Don't change them!) See the class
for the full descriptions.
In previous versions, the properties
used for context specific information. Since TYPO3 v9 these variables have been
replaced by the TYPO3 Context API.
If you for instance want to access the variable "id", you can do so by
The page id
The page record
The current front-end user.
User record in
$GLOBALS['TSFE']->fe_user->user, if any login.
The rootLine (all the way to tree root, not only the current site!).
Current site root line is in
The object with page functions (object) See
The backend user object (if any).
Main frontend object.