如何在 Silverstripe CMS 编辑器中将 css class 添加到 href?
How to add a css class to an href in Silverstripe CMS editor?
如何在 silverstripe CMS 编辑器中将 Class 添加到 href
或任何其他 css 元素?
我在 editor.css
样式表中添加了自定义 css Class。
我希望 link 看起来像这样:
<a href="http://www.example.com" class="my-custom-class">Click me</a>
我尝试这样做的方式最终得到了这个结果(例如,它在 link 周围包装了一个 <p>
标签):
<p class="my-custom-class">
<a href="http://www.example.com">Click me</a>
</p>
我知道您可以使用 CMS 编辑器中的 HTML 源代码编辑器手动添加 class 但我想尽可能避免这样做。
如 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);
如何在 silverstripe CMS 编辑器中将 Class 添加到 href
或任何其他 css 元素?
我在 editor.css
样式表中添加了自定义 css Class。
我希望 link 看起来像这样:
<a href="http://www.example.com" class="my-custom-class">Click me</a>
我尝试这样做的方式最终得到了这个结果(例如,它在 link 周围包装了一个 <p>
标签):
<p class="my-custom-class">
<a href="http://www.example.com">Click me</a>
</p>
我知道您可以使用 CMS 编辑器中的 HTML 源代码编辑器手动添加 class 但我想尽可能避免这样做。
如 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);