如何href
在silverstripe CMS编辑器中向一个或其他任何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的出色TinyTidy模块中所见,您可以在/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);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句