2012-01-26 53 views
1

我用表單製作了一個簡單的插件,但是當我沒有登錄時不會發布。
這裏是class.tx_gctest_pi1.php文件, Kickstarter的。未登錄時無法提交Typo3表格

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']); 
} 

?> 

並沒有登錄時沒有登錄時,這將輸出測試。 重新加載頁面,但沒有交送到

+4

看起來你應該讓你的插件USER_INT。 詳細信息:http://stackoverflow.com/questions/293021/typo3-setting-plugin-as-of-the-user-int-type –

回答

0

我認爲這並沒有很多工作要做,登錄/註銷。除非您告訴它不緩存,否則TYPO3會緩存內容。

echovar_dumpprint_rdebug是通過php直接顯示事物的方法。 TYPO3沒有抓住他們。如果您想顯示某些內容,請將其添加到$content並在main()的末尾返回$contentmain()的返回值被緩存。

您可以通過清除在後臺緩存試試這個並刷新頁面。顯示echo等。在重新加載之後,它就消失了。

那麼,該如何解決?有幾個可能性

  • 使包含您的插件未緩存
  • 使插件本身未緩存

我建議你找出你真正想做的事,然後編寫代碼的頁面那就是使用緩存。

+0

插件只是一個小表單,用戶在其中寫入他們的電子郵件地址和插件會向他們發送電子郵件並將一些內容存儲在數據庫中。我怎樣才能使插件解除緩存? – Patrik

+2

這個**確實與**沒有關係。您的擴展在緩存時無法工作,因爲它不會被調用。登錄後,TYPO3禁用緩存,這就是它的原因。解決方案是禁用緩存你的插件。查看Fedir發佈的關於您問題的評論的鏈接,並查看Mehdi Guermazi的答案。 – tmt