[Typo3] How to get parent id of current page?

Dmitry Dulepov typo3 at fm-world.ru
Thu Oct 27 12:08:46 CEST 2005


Hi!

PaweЁ StanisЁawczuk wrote:
> Hello,
> 
> Another question is how to get PID's of some level i.e
> 
> root
> --main1(uid:1)
> ----sub1(uid:3)
> ----sub2(uid:4)
> ----sub3(uid:5)
> ------subsub1(uid:7)
> ------subsub2(uid:8)
> --main2(uid:2)
> ----sub1(uid:6)
> 
> To get the UID of main level, while surfin' in subsub level, how to do that?

You can easily get *root* page this way:

        $GLOBALS['TSFE']->getPageAndRootline();
        $res = $GLOBALS['TSFE']->getStorageSiterootPids();
        if (is_array($res) && isset($res['_SITEROOT'])) {
            $siteroot_uid = $res['_SITEROOT'];
        }

For "any page" you can walk through $GLOBALS['TSFE']->rootLine array.
You still have to call $GLOBALS['TSFE']->getPageAndRootline() first.

Btw, $GLOBALS['TSFE']->getPageAndRootline() is marked as private but it
is very convinient to use. Not sure why it was marked as private.

Dmitry.



More information about the TYPO3-english mailing list