2015-12-03 54 views
0

我在其中一個擴展中創建了一個新的CommandController,我現在需要做的是添加一個附加字段,其中後端用戶可以插入一些可在CommandController內使用的數據。typo3 extbase:如何在CommandController中定義附加值

我試圖谷歌這一點,我發現一些有關additionalFieldsfieldProdiver,但我覺得沒有什麼的有關該extbase CommandController功能。

我會就如何實現這一目標的任何提示,非常感謝。

+1

也許這有助於(其德國不好意思):http://www.codesnip.de/snippets/beispiel-fuer-einen-commandcontroller.html – brandelizer

+0

代碼格式化 – lalibi

回答

0

所說的「additionalFields」如果我得到你的問題,那麼你需要更多的領域獲得從後臺管理員的更多信息。

在extBase:

步驟1:附加字段插入擴展SQL文件
添加字段中ext_tables.sql文件,位於

YOUR_EXTENSION/ext_tables.sql

CREATE TABLE tx_YOUREXTENSION_domain_model_TABLENAME (
    /**your existing fields... **/ 
    newfield varchar(255) DEFAULT '' NOT NULL, // add new 
); 

第2步:比較數據庫和更新安裝工具
轉到後端>安裝工具>「與規格比較當前數據庫」 並進行更新。

第3步: TCA

YOUR_EXTENSION /配置/ TCA/Command.php


1. "showRecordFieldList" => "newfield" 
2. "showitem" => "newfield" 

陣列添加字段名稱現在你有到config你的領域:

'newfield' => array(
    'exclude' => 1, 
    'label' => 'YOUR_LABLE', 
    'config' => array(
     'type' => 'input', 
     'size' => 30, 
     'eval' => 'trim' 
    ), 
), 

更多場配置,看到TCA Reference

步驟4:模型[獲取設定方法]

YOUR_EXTENSION /類別/域/型號/ Command.php

/** 
* newfield 
* 
* @var string 
*/ 
protected $newfield = ''; 

/** 
* Returns the newfield 
* 
* @return string $newfield 
*/ 
public function getNewfield() { 
    return $this->newfield; 
} 

/** 
* Sets the newfield 
* 
* @param string $newfield 
* @return void 
*/ 
public function setNewfield($newfield) { 
    $this->newfield= $newfield; 
} 

步驟5:清除緩存
最後也是最重要的;)明確安裝工具緩存