-
Root page id from dca
Hello,
just a simple question, is there a better way to get root page id from dca plugin that fetching it step by step from database:
PHP Code:
$pid = $dca->activeRecord ->pid;
do
{
$objPage = $this ->Database ->prepare("SELECT id,pid FROM tl_page WHERE id=?")
->limit(1)
->execute($pid);
if ( $objPage->numRows < 1 )
{
break;
}
$rootId = $objPage->id;
$pid = $objPage->pid;
}
while ( $pid > 0 && $objPage->type != 'root' );
maybe it is already stored somewhere...? thanks
-
are you talking about frontend or backend?
in backend you can use findPublishedRootPages from PagesModel class
in frontend you can use getRootPageFromUrl from Frontend class
-
Hi there,
I am also looking for the same way to find the root page to which the current Content Element associated in Backend.
\PageModel::findPublishedRootPages(); will give you all the published root pages, but there is no way to find, to which root the content element in the backend it attached.
Is there a better way?