未登录时无法提交Typo3表格

时间:2012-01-26 08:48:15

标签: php typo3

我制作了一个带有表单的简单插件,但是当我没有登录时它不会发布 这是使用Kickstarter创建的文件class.tx_gctest_pi1.php。

require_once(PATH_tslib.'class.tslib_pibase.php');

class tx_gctest_pi1 extends tslib_pibase {
    var $prefixId      = 'tx_gctest_pi1';       // Same as class name
    var $scriptRelPath = 'pi1/class.tx_gctest_pi1.php'; // Path to this script relative to the extension dir.
    var $extKey        = 'gc_test'; // The extension key.
    var $pi_checkCHash = true;

    function main($content, $conf) {
        $this->conf = $conf;
        $this->pi_setPiVarDefaults();
        $this->pi_loadLL();

        if($_POST) {
            echo 'test';
        }

        $content='
            <strong>This is a few paragraphs:</strong><br />
            <p>This is line 1</p>
            <p>This is line 2</p>

            <h3>This is a form:</h3>
            <form action="'.$this->pi_getPageLink($GLOBALS['TSFE']->id).'" method="POST">
                <input type="text" name="'.$this->prefixId.'[input_field]" value="'.htmlspecialchars($this->piVars['input_field']).'">
                <input type="submit" name="'.$this->prefixId.'[submit_button]" value="'.htmlspecialchars($this->pi_getLL('submit_button_label')).'">
            </form>
            <br />
            <p>You can click here to '.$this->pi_linkToPage('get to this page again',$GLOBALS['TSFE']->id).'</p>
        ';

        return $this->pi_wrapInBaseClass($content);
    }
}



if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/gc_test/pi1/class.tx_gctest_pi1.php']) {
    include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/gc_test/pi1/class.tx_gctest_pi1.php']);
}

?>

这将在登录时输出测试,在未登录时输出任何内容。 页面已重新加载但未发送帖子

1 个答案:

答案 0 :(得分:0)

我认为这与登录/退出没什么关系。除非您告诉内容不缓存,否则TYPO3会缓存内容。

echo var_dump print_r debug是通过php直接显示内容的方法。 TYPO3没有捕获它们。如果您想要显示某些内容,请将其添加到例如$content并在$content结束时返回main()main()的返回值被缓存。

您可以通过清除后端缓存并刷新页面来尝试此操作。显示echo等。在重新加载之后,它就消失了。

那么,如何解决这个问题呢?有几种可能性

  • 使包含您的插件的页面无法使用
  • 使插件本身未缓存

我建议你找出你真正想做的事情然后编写你正在使用缓存的代码。