Results 1 to 2 of 2

Thread: Root page id from dca

  1. #1
    New user
    Join Date
    10-15-18.
    Posts
    8

    Default 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 )
        {
            break;
        }
        
    $rootId $objPage->id;
        
    $pid $objPage->pid;
    }
    while ( 
    $pid && $objPage->type != 'root' ); 
    maybe it is already stored somewhere...? thanks

  2. #2
    User
    Join Date
    06-19-09.
    Posts
    326

    Default

    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
    Consulenza Contao CMS https://www.intco.it

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •