如何在silverstripe CMS编辑器中将类添加到href或任何其他css元素?
我在editor.css样式表中添加了一个自定义css类.
我希望链接看起来像这样:
<a href="http://www.example.com" class="my-custom-class">Click me</a>
我尝试这样做的方式最终得到了这个结果(例如,它在链接周围包含了一个< p>标记):
<p class="my-custom-class">
<a href="http://www.example.com">Click me</a>
</p>
我意识到你可以使用CMS编辑器中的HTML源代码编辑器手动添加类,但是如果可以的话我想尽量避免这样做.
最佳答案 如
jonom’s great TinyTidy module所示,您可以尝试使用/mysite/_config.php:
$formats = array(
// Links
array(
'title' => 'Links'
),
array(
'title' => 'Arrow',
'attributes' => array('class'=>'arrow'),
'selector' => 'a'
),
array(
'title' => 'Button',
'attributes' => array('class'=>'button'),
'selector' => 'a'
),
);
//Set the dropdown menu options
HtmlEditorConfig::get('cms')->setOption('style_formats',$formats);