Search code examples
typo3typo3-7.6.xtypolink

TYPO3 7.6.12 Call to a member function getPage_noCheck() on string


I don't know why my Extension throws this error. Because other extensions like dd_googlesitemap use it in same way as me and this extension do not throw this error.

What am I doing wrong with my $pageId param:

/**
 * Creates a link to a single page
 *
 * @param   array   $pageId Page ID
 * @return  string  Full URL of the page including host name (escaped)
 */
protected function getPageLink($pageId) {
    $conf = array(
        'parameter' => $pageId,
        'returnLast' => 'url',
    );

    $link = htmlspecialchars($this->cObj->typoLink('', $conf));
    return GeneralUtility::locationHeaderUrl($link);
}

And this is the error output:

Call to a member function getPage_noCheck() on string 

It is the method detectLinkTypeFromLinkParameter on line 6364.

Why do I get this error?


Solution

  • This error appears because the $GLOBAL['TSFE'] isn´t initialized at the time I try to use it. After initialization it throws no more errors and works well.

    Update: For those who are still searching for this solution and still using typo3 7.6: Search for the method initTSFE where it is defined on line 208 (this is the method to init the "TSFE") and where it is initialized on line 94 before getPageLink method Here the link to the file https://ideone.com/f4TGMm