“附加字段”的意思如果我收到您的问题,那么您需要更多字段才能从后端管理员那里获取更多信息。
在 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/Configuration/TCA/Command.php
将您的字段名称添加到数组
1. "showRecordFieldList" => "newfield"
2. "showitem" => "newfield"
现在你必须配置你的字段:
'newfield' => array(
'exclude' => 1,
'label' => 'YOUR_LABLE',
'config' => array(
'type' => 'input',
'size' => 30,
'eval' => 'trim'
),
),
更多字段配置见TCA Reference
第四步:模型[get set方法]
YOUR_EXTENSION/Classes/Domain/Model/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 步:清除缓存
最后也是最重要的 ;) 清除安装工具缓存