nathancox/customhtmleditorfield

允许在 SilverStripe 中为每个编辑器配置 TinyMCE 和正文类

1.1.0 2017-05-21 01:29 UTC

This package is not auto-updated.

Last update: 2024-09-11 12:10:42 UTC


README

概览

此模块为 SilverStripe 3 中的 HTMLEditorField 添加了两个功能

  1. 允许您为每个编辑器字段设置自定义的正文类(用于不同样式的内容)
  2. 允许您为每个 HTMLEditorField 分配不同的 HTMLEditorConfigs(例如,拥有不同的工具栏)

维护者联系方式

要求

  • SilverStripe 3.3+

安装说明

  1. 将文件放置在 SilverStripe 安装根目录下的 customhtmleditorfield 目录中。您可以通过 composer require nathancox/customhtmleditorfield 最容易地完成此操作
  2. 访问 yoursite.com/dev/build 以重建数据库

文档

示例代码

<?php

// in _config.php:

// make a new TinyMCE config called "footer" by copying the default ("cms") config
$footerConfig = CustomHtmlEditorConfig::copy('footer', 'cms');
// remove the third row of the editor toolbar: no tables in the footer!
$footerConfig->setButtonsForLine(3, array());


// in getCMSFields()

// make an HtmlEditorField
$fields->addFieldToTab('Root.Footer', $footerField = new HtmlEditorField('FooterText', 'Footer'));

// assign the "footer" TinyMCE config to this field
$footerField->setEditorConfig('footer');

// set the editor's body class.  This will make it class="typography footer-content"
$footerField->setBodyClass('footer-content');

如果配置在 getCMSFields() 中定义,则仅在 CMS 在页面部分打开或刷新时才会工作。如果直接在另一个部分,例如文件中打开窗口并导航到页面,则无法加载在 getCMSFields 中定义的配置。

已知问题

问题跟踪器