Add Bootstrap class-names to Typo3 tables

亡梦爱人 提交于 2019-12-01 20:11:47

问题


Is there a possibility to add Bootstrap table-classes to tables created in Typo3 v6.1? I have noticed the setting "Additional CSS Class" when creating a page of type "Table", but:

  1. it doesn't add any classes to my table
  2. it doesn't support adding multiple classes (commas, spaces etc. get stripped when saving)

I would to add class="table table-hover" to any table I create. Also, I don't think that I need the default class "contenttable".


回答1:


From your post, I assume that you are using the content element table, not a table in the RTE.

Overriding the classes of the RTE would be easy (in TypoScript setup):

lib.parseFunc_RTE {
    externalBlocks {
        table.stdWrap.HTMLparser.tags.table.fixAttrib.class {
            default = table table-hover
            always = 1
            list >
        }
    }
}

(The TYPO3 default is "contenttable".)

Overriding the classes of the table CE is harder. Only the FlexForm value is respected, if it is not set, it falls back to the standard classes, see https://git.typo3.org/Packages/TYPO3.CMS.git/blob/HEAD:/typo3/sysext/css_styled_content/Classes/Controller/CssStyledContentController.php#l130

You will find two solutions in How to generate <table> compatible with jQueryMobile in TYPO3. The first one seems the best to me, the second one looks very hacky.




回答2:


This has been fixed in the TYPO3 core, so you can use multiple classes in the regular table element now. See Bugfix #55470 on forge



来源:https://stackoverflow.com/questions/20648083/add-bootstrap-class-names-to-typo3-tables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!