Following script you will get root page id of current page. $GLOBALS['TSFE']->rootLine[0]['uid']; you may get all tree level from following typo syntax. $GLOBALS['TSFE']->rootLine; I hope it will work for you :)