TYPO3 4.7与ext:getcontentbyajax

时间:2012-11-02 11:12:08

标签: ajax typo3 frontend

在TYPO3 ver中,Ext getcontentbyajax不会生成json输出。 4.7。它调用500内部服务器错误。在serverlog中,我发现错误位于/lib/class.tx_getcontentbyajax.php的第42行。 switch(t3lib_div::_GP('todo')){ 我发现了4.7问题: http://lists.typo3.org/pipermail/typo3-german/2012-September/087865.html

t3lib_div::GPvar()更改为t3lib_div::_GP()

当您将所有GPvar更改为_GP时,扩展程序正常工作。

这里改变的方法main()形式为getcontentbyajax扩展名的/lib/class.tx_getcontentbyajax.php:

public function main(){

    switch(t3lib_div::_GP('todo')){ 
        case 'pagebrowser':
            $href = str_replace(t3lib_div::getIndpEnv('TYPO3_SITE_URL'), '', t3lib_div::_GP('href')); // IE6 has problems
            $requestedPage = file_get_contents(urldecode(t3lib_div::getIndpEnv('TYPO3_SITE_URL') . $href));
            /*preg_match('/<div.*?id\=[\"]{0,1}' . t3lib_div::GPvar('part') . '[\"]{0,1}.*?>[\r\n]{0,2}<!--ajaxreplace-->[\s]{0,}(.*?)[\s]{0,}<!--ajaxreplace-->[\r\n]{0,2}<\/div>/s', $requestedPage, $matches);*/
            preg_match('/<!--ajaxreplace-->(.*?)<!--ajaxreplace-->/s', $requestedPage, $matchesContent);
            preg_match('/<title>(.*?)<\/title>/s', $requestedPage, $matchesTitle);

            if(array_key_exists(1, $matchesContent)){
                if(array_key_exists(1, $matchesTitle)){
                    $this->data['title'] = $matchesTitle[1];
                }
                $this->data['content'] = $matchesContent[1];
                $this->data['success'] = true;
            } else {
                $this->data['content'] = 'An error occured, please reload the site or <a href="' . t3lib_div::_GP('href') . '" class="no-ajax">click this link</a> to load your desired page.';
                $this->data['success'] = false;
            }

            // hook
            if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['getcontentbyajax']['mainHook'])){
                foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['getcontentbyajax']['mainHook'] as $_classRef){
                    $_procObj = & t3lib_div::getUserObj($_classRef);
                    $this->data = $_procObj->extraGlobalMarkerProcessor($this, $this->data);
                }
            }
        break;
    }
    echo json_encode($this->data);
}

0 个答案:

没有答案