Tsfe 

\nn\t3::Tsfe() 

Everything about the Typo3 frontend. Methods for initializing the FE from the backend context, access to the cObj and cObjData etc.

Overview of Methods 

\nn\t3::Tsfe()->bootstrap($conf = []); 

Bootstrap Typo3

\nn\t3::Tsfe()->bootstrap();
\nn\t3::Tsfe()->bootstrap( ['vendorName'=>'Nng', 'extensionName'=>'Nnhelpers', 'pluginName'=>'Foo'] );
Copied!

| ➜ Go to source code of Tsfe::bootstrap()

\nn\t3::Tsfe()->cObj($request = NULL); 

Get $GLOBALS['TSFE']->cObj.

// since TYPO3 12.4 within a controller:
\nn\t3::Tsfe()->cObj( $this->request )
Copied!

| @return \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer

| ➜ Go to source code of Tsfe::cObj()

\nn\t3::Tsfe()->cObjData($request = NULL, $var = NULL); 

Get $GLOBALS['TSFE']->cObj->data.

\nn\t3::Tsfe()->cObjData( $this->request ); => array with DB-row of the current content element
\nn\t3::Tsfe()->cObjData( $this->request, 'uid' ); => uid of the current content element
Copied!

| @return mixed

| ➜ Go to source code of Tsfe::cObjData()

\nn\t3::Tsfe()->cObjGetSingle($type = '', $conf = []); 

Render a TypoScript object. Earlier: $GLOBALS['TSFE']->cObj->cObjGetSingle()

\nn\t3::Tsfe()->cObjGetSingle('IMG_RESOURCE', ['file'=>'image.jpg', 'file.'=>['maxWidth'=>200]] )
Copied!

| ➜ Go to source code of Tsfe::cObjGetSingle()

\nn\t3::Tsfe()->forceAbsoluteUrls($enable = true); 

Sets config.absRefPrefix to the current URL.

This means that when rendering the links of content elements absolute URLs are used. Does not (yet) work for images.

\nn\t3::Environment()->forceAbsoluteUrls();
$html = \nn\t3::Content()->render(123);
Copied!

| ➜ Go to source code of Tsfe::forceAbsoluteUrls()

\nn\t3::Tsfe()->get($pid = NULL); 

Get $GLOBALS['TSFE']. If not available (because in BE) initialize.

\nn\t3::Tsfe()->get()
\nn\t3::Tsfe()->get()
Copied!

| @return \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController

| ➜ Go to source code of Tsfe::get()

\nn\t3::Tsfe()->includeHiddenRecords($includeHidden = false, $includeStartEnd = false, $includeDeleted = false); 

Get hidden content elements in the frontend. Can be used before rendering.

\nn\t3::Tsfe()->includeHiddenRecords(true, true, true);
$html = \nn\t3::Content()->render(123);
Copied!
@param bool $includeHidden
@param bool $includeStartEnd
@param bool $includeDeleted
@return void

| ➜ Go to source code of Tsfe::includeHiddenRecords()

\nn\t3::Tsfe()->init($pid = 0, $typeNum = 0); 

Initialize the $GLOBALS['TSFE'] Only used for compatibility with older code that still uses $GLOBALS['TSFE'].

// Get TypoScript the 'old' way
$pid = \nn\t3::Page()->getPid();
\nn\t3::Tsfe()->init($pid);
$setup = $GLOBALS['TSFE']->tmpl->setup;
Copied!
@param int $pid
@param int $typeNum
@return void

| ➜ Go to source code of Tsfe::init()

\nn\t3::Tsfe()->injectTypoScript($request = NULL); 

Inject fully initialized TypoScript into the request.

This is necessary when executing in a cached frontend context in which the TypoScript setup array is not initialized. It uses the TypoScriptHelper to create a complete TypoScript object and place it into the frontend.typoscript attribute of the request.

// In the middleware:
$request = \nn\t3::Tsfe()->injectTypoScript( $request );
Copied!
@param \TYPO3\CMS\Core\Http\ServerRequest $request
@return \TYPO3\CMS\Core\Http\ServerRequest

| ➜ Go to source code of Tsfe::injectTypoScript()

\nn\t3::Tsfe()->softDisableCache($request = NULL); 

Deactivate cache for the frontend.

"Soft" variant: Uses a fake USER_INT object so that already rendered elements elements do not have to be rendered again. Workaround for TYPO3 v12+, since TypoScript Setup & Constants are no longer initialized when page is completely loaded from the cache.

\nn\t3::Tsfe()->softDisableCache()
Copied!
@param \TYPO3\CMS\Core\Http\ServerRequest $request
@return \TYPO3\CMS\Core\Http\ServerRequest

| ➜ Go to source code of Tsfe::softDisableCache()

Methods