I have made a simple plugin with a form but it won’t post when I’m not logged in.
Here is the file class.tx_gctest_pi1.php, created with Kickstarter.
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']);
}
?>
This will output test when logged in and nothing when not logged in.
The page is reloaded but no post is sent
I think this has not much to do with logged in / logged out. TYPO3 caches content unless you tell it to not cache.
echovar_dumpprint_rdebugare methods that directly display things through php. TYPO3 doesn’t catch them. If you want to have something displayed, add it to e.g.$contentand return$contentat the end ofmain(). The return value ofmain()gets cached.You can try this by clearing your cache in backend and refresh the page.
echoetc is displayed. after a new reload, it is gone.So, how to solve this? There are a few possibilities
I would suggest you find out what you really want to do and then write your code that is is using caching.