Attention
TYPO3 v11 has reached end-of-life as of October 31th 2024 and is no longer being maintained. Use the version switcher on the top left of this page to select documentation for a supported version of TYPO3.
Need more time before upgrading? You can purchase Extended Long Term Support (ELTS) for TYPO3 v10 here: TYPO3 ELTS.
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
\TYPO3\
in the
EXT:frontend/Classes/ContentObject/ContentObjectRenderer.php (GitHub)
script. Thereby your file is a part of this object
(Content
). 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_
)
$content
Contains the content, which was passed to the object, if any. All content, which you want to return, must be in this variable.
Do not output anything directly in your script.
$conf
The array $conf
contains the configuration for the USER cObject.
Try debug
to see the content printed out for debugging!
White spaces
Because nothing is sent off to the browser before everything is
rendered and returned to \TYPO3\
(which originally set off the rendering process), you must ensure
that there's no whitespace before your <?php
tag
in your include or library scripts! You should not use the closing PHP tag
?>
.
$GLOBALS['TSFE']->set_no_cache()
Call the function $GLOBALS
, 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 $GLOBALS
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_
, which is
rendered after the cached page!
Example:
$GLOBALS['TSFE']->set_no_cache();
ContentObjectRenderer::cObjGetSingle(value, properties[, TSkey = '__'])
A method of \TYPO3\
.
Gets a content object from the $conf
array.
Example:
$content = $cObjectRenderer->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!
ContentObjectRenderer::stdWrap(value, properties)
A method of \TYPO3\
.
Hands the content in "value" to the stdWrap function, which will process it according to the configuration of the array "properties".
Example:
$content = $cObjectRenderer->stdWrap($content, $conf['stdWrap.']);
This will stdWrap the content with the properties of .std
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: Do not change them!) See the class
\TYPO3\
for the
full descriptions.
You can retrieve the Typo
via the
request attribute
frontend.controller.
For instance, if you want to access the variable id
, you can do so by
writing: Typo
.
TypoScriptFrontendController->id
id
-
- Type
- integer
The current page id
TypoScriptFrontendController->type
type
-
- Type
- integer
The type
TypoScriptFrontendController->page
page
-
- Type
- array
The page record
TypoScriptFrontendController->feuser
fe_user
-
- Type
- array
The frontend user record
User record in
$GLOBALS
, if any login. Better use the request attribute frontend.user instead.['TSFE']->fe_ user->user
TypoScriptFrontendController->rootLine
rootLine
-
- Type
- array
The root line (all the way to tree root, not only the current site!). Current site root line is in
\TYPO3\
.CMS\ Frontend\ Controller\ Typo Script Frontend Controller->config ['root Line']
TypoScriptFrontendController->table-row
rootLine
-
- Type
- object
The object with page functions (object) See
EXT:
.core/ Classes/ Domain/ Repository/ Page Repository. php
Global variables
$GLOBAL['BE_USER']
$GLOBAL['BE_USER']
-
- Type
- object
The backend user object. See Backend user object for more information.
$GLOBAL['TYPO3_CONF_VARS']
$GLOBAL['TYPO3_CONF_VARS']
-
- Type
- object
TYPO3 configuration variables. See TYPO3_CONF_VARS for more information.
$GLOBAL['TYPO3_CONF_VARS']
$GLOBAL['TSFE']
-
- Type
- object
Main frontend object. Whenever possible, use the request attribute frontend.controller instead. See also TSFE.