【问题标题】:SilverStripe Fluent field iconsSilverStripe Fluent 字段图标
【发布时间】:2016-04-24 09:37:51
【问题描述】:

在后端,SilverStripe Fluent 模块添加了一个绿色标志图标,表示该字段是可翻译的(如页面名称、URL 段和内容旁边所示)。

这是一个用户友好的细节,我希望它适用于自定义添加的可翻译的 CMS 字段。例如,我添加了一个名为 Introduction 的自定义字段,并使其可使用:private static $translate = array( 'Introduction' ); 进行翻译,但它旁边没有绿色图标。 可以添加吗?

【问题讨论】:

标签: php silverstripe


【解决方案1】:

必须在$fields = parent::getCMSFields(); 之前添加$this->beforeUpdateCMSFields(function($fields) { ... } 并将所有可翻译字段放入其中,如下所示:

function getCMSFields() {

    //This needs to be added for Fluent to apply css
    $this->beforeUpdateCMSFields(function($fields) {
        //Translatable field
        $fields->addFieldToTab("Root.Main", new TextAreaField('Introduction','Introduction'), 'Content');
    });

    $fields = parent::getCMSFields();

    //Non-translatable field
    $fields->addFieldToTab("Root.Main", $uploadField = new UploadField('Slideshow', 'Slideshow Images'), 'Content');

    return $fields;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-22
    • 2016-12-19
    • 2020-02-13
    • 1970-01-01
    • 2017-11-17
    • 1970-01-01
    相关资源
    最近更新 更多