Zum Inhalt springen

Inhalt von Button überprüfen

Erstellt am 8. November 2012 · 6 Antworten · letzte Antwort am 9. November 2012

Tags: PHP, Frage

amm0 ·

Servus

ich erstelle gerade eine Extension, bei der der Button auf abgefragt werden soll und den "IF"-Zweig abarbeiten soll.

Vorab mein Code:

<?php
/***************************************************************
 *  Copyright notice
 *
 *  (c) 2012 Raphael Amorisco <ramorisco@googlemail.com>
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
 *  free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  The GNU General Public License can be found at
 *  http://www.gnu.org/copyleft/gpl.html.
 *
 *  This script is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  This copyright notice MUST APPEAR in all copies of the script!
 ***************************************************************/

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

/**
 * Plugin 'Reporting_Sys' for the 'reporting_sys' extension.
 *
 * @author	Raphael Amorisco <ramorisco@googlemail.com>
 * @package	TYPO3
 * @subpackage	tx_reportingsys
 */
class tx_reportingsys_pi1 extends tslib_pibase {
	public $prefixId      = 'tx_reportingsys_pi1';		// Same as class name
	public $scriptRelPath = 'pi1/class.tx_reportingsys_pi1.php';	// Path to this script relative to the extension dir.
	public $extKey        = 'reporting_sys';	// The extension key.
	public $pi_checkCHash = TRUE;
	
	/**
	 * The main method of the Plugin.
	 *
	 * @param string $content The Plugin content
	 * @param array $conf The Plugin configuration
	 * @return string The content that is displayed on the website
	 */
	public function main($content, array $conf) {
		$this->conf = $conf;
		$this->pi_setPiVarDefaults();
		$this->pi_loadLL();
		
		
		 if(!empty($this->piVars['submit_button'])) {
			$content = ' "Jetzt wurde das formular übetragen!" ';
		}else{ 
			$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') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/reporting_sys/pi1/class.tx_reportingsys_pi1.php'])) {
	include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/reporting_sys/pi1/class.tx_reportingsys_pi1.php']);
}

?>

Woran liegt es, dass er nicht in den IF-Zweig geht ? #angry#

SomehowLost ·

Servus zurück,

aller Wahrscheinlichkeit nach wird Dein Formular gecached.
Wenn das der Fall ist (prüfe das doch einfach mal indem Du nach abschicken des Formualrs einfach die Seite neu lädst: Kommt dann die richtige Ausgabe?), setz das Caching für das Plugin einfach aus.

Viele Grüße

amm0 ·

ja genau, wenn ich irgendwas am code verändert habe, und anschließend F5 drücke, dann kommt die richtige ausgabe, wenn ich aber einfach wieder auf die seite klicke, dann gibt er den falschen inhalt aus.

Wie kann ich das caching deaktivieren ?

SomehowLost ·

Also entweder Du sezt die ganze Seite auf config.no_cache = 1 (oder im Plugin selber per $GLOBALS) oder beim Plugin kannst Du im Extension-Manager sagen, dass das Plugin von Typ USER_INT ist.

Viele Grüße

amm0 ·

Finde es im extension manager nicht, wo genau kann ich das ändern ?

//EDIT:

oder meinst du folgendes :

    function main($content,$conf) {
        [...]
        $this->pi_USER_INT_obj = 1;
        [...]
      }