I'm using TYPO3 v8, how can I get the id of the current page that I'm editing in the backend?
How to get ID of current page in TYPO3 backend
You can get current PageId
like this.
in Controller file.
$currentPid = $GLOBALS['TSFE']->id
Using Typoscript.
temp.page_uid = TEXT
temp.page_uid.field = uid
I tried this "$currentPid = $GLOBALS['TSFE']->id" and it didn't work ! I like to get the id of the current page in backoffice inside an extension that I have created and I don't have any controllers –
Mender
The question specifically asked "in the backend". $GLOBALS['TSFE'] is instantiated in the frondend. –
Pulitzer
Example: In your controller:
$id = (int)\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id');
Just a hint: _GP('id') is only set when you have chosen a page in the page tree. Therefore, be aware of empty values - or zero when cast to integer as above. –
Veracity
This depends on context, examples:
- If you are extending FormEngine (editing records), the parent page record is in the data array, prepared by some rather early data provider.
- If you are adding a feature to the 'info' module, the page id is a GET parameter, you should be able to access this in your controller.
© 2022 - 2024 — McMap. All rights reserved.