Created
January 7, 2014 14:51
-
-
Save foertel/8300385 to your computer and use it in GitHub Desktop.
BackendConfigurationManager->getCurrentPageId()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Returns the page uid of the current page. | |
* If no page is selected, we'll return the uid of the first root page. | |
* | |
* @return integer current page id. If no page is selected current root page id is returned | |
*/ | |
protected function getCurrentPageId() { | |
$pageId = (integer) \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id'); | |
if ($pageId > 0) { | |
return $pageId; | |
} | |
// get current site root | |
$rootPages = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', 'pages', 'deleted=0 AND hidden=0 AND is_siteroot=1', '', '', '1'); | |
if (count($rootPages) > 0) { | |
return $rootPages[0]['uid']; | |
} | |
// get root template | |
$rootTemplates = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('pid', 'sys_template', 'deleted=0 AND hidden=0 AND root=1', '', '', '1'); | |
if (count($rootTemplates) > 0) { | |
return $rootTemplates[0]['pid']; | |
} | |
// fallback | |
return self::DEFAULT_BACKEND_STORAGE_PID; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment