Attention

TYPO3 v6 has reached its end-of-life April 18th, 2017 and is not maintained by the community anymore. Looking for a stable version? Use the version switch on the top left.

There is no further ELTS support. It is strongly recommended updating your project.

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 by a function, PHP_SCRIPT, inside the class "ContentObjectRenderer" (tslib_cObj) in the typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php (tslib_content.php) script. Thereby your file is a part of this object (ContentObjectRenderer, respectively tslib_cObj) and function. 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()!)

$content

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!

$conf

The array $conf contains the configuration for the PHP_SCRIPT cObject. Try debug($conf) 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\CMS\Frontend\Http\RequestHandler (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!

$GLOBALS['TSFE']->set_no_cache()

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 $GLOBALS['TSFE']->set_no_cache() 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 PHP_SCRIPT and not for PHP_SCRIPT_INT and PHP_SCRIPT_EXT, which are rendered after the cached page!

Example:

$GLOBALS['TSFE']->set_no_cache();

$this->cObjGetSingle(value, properties)

Gets a content object from the $conf array.

Example:

$content = $this->cObjGetSingle($conf['image'], $conf['image.']);

This would return any IMAGE cObject at the property "image" of the $conf array for the include script!

$this->stdWrap(value, properties)

Hands the content in "value" to the stdWrap function, which will process it according to the configuration of the array "properties".

Example:

$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 TypoScriptFrontendController (tslib_fe) for the full descriptions.

If you for instance want to access the variable "id", you can do so by writing: $GLOBALS['TSFE']->id

Variable

id

PHP-Type

integer

Description

The page id

Variable

type

PHP-Type

integer

Description

The type

Variable

page

PHP-Type

array

Description

The page record

Variable

fe_user

PHP-Type

object

Description

The current front-end user.

User record in $GLOBALS['TSFE']->fe_user->user, if any login.

Variable

loginUser

PHP-Type

boolean

Description

Flag indicating that a front-end user is logged in.

Default

0

Variable

rootLine

PHP-Type

array

Description

The rootLine (all the way to tree root, not only the current site!). Current site root line is in $GLOBALS['TSFE']->tmpl->rootLine

Variable

sys_page

PHP-Type

object

Description

The object with page functions (object) See typo3/sysext/frontend/Classes/Page/PageRepository.php (t3lib/class.t3lib_page.php).

Variable

gr_list

PHP-Type

string (list)

Description

The group list, sorted numerically. Group -1 = no login

Variable

beUserLogin

PHP-Type

boolean

Description

Flag that indicates if a Backend user is logged in!

Default

0

Global variables

Variable

BE_USER

PHP-Type

object

Description

The backend user object (if any).

Default

not set

Variable

TYPO3_CONF_VARS

PHP-Type

array

Description

TYPO3 Configuration.

Variable

TSFE

PHP-Type

object

Description

Main frontend object.