我需要在typo3 7.6中构建扩展。我在setup.txt中使用
包含一个css文件page.IncludeCSS = Ext.Path_to_css_file.css
但我的css文件中的样式被其他一些自定义样式覆盖。如何防止这种情况。任何想法?我是typo3的新手。请帮助我。提前谢谢你。
答案 0 :(得分:1)
您必须为每个要包含唯一键的css文件(例如myCssFile1
)。在EXT:
之后也使用冒号。因此,使用TypoScript包含CSS文件的正确方法是
page.includeCSS.myCssFile1 = EXT:my_ext/Path/to/css_file.css
答案 1 :(得分:1)
“页面。我 ncludeCSS”错误,应该是“page.includeCSS”,后跟您自定义的唯一数组名称,如:
page.includeCSS {
styles=Resources/Public/Stylesheets/style.css
form=fileadmin/css/form.css
jqueryui=Resources/Public/Javascript/ui/jquery-ui.min.css
}
问候 皮特
答案 2 :(得分:0)
另一种方法,脏但没有编辑扩展模板:
lib.additionalStyles = HMENU
lib.additionalStyles {
special = rootline
special.range = 0|-1
includeNotInMenu = 1
1 = TMENU
1.NO {
doNotShowLink = 1
before.cObject = FILES
before.cObject {
references {
table = pages
uid.data = field:uid
fieldName = media
}
renderObj = TEXT
renderObj {
if.value = css
if.equals.data = file:current:extension
dataWrap = <link rel="stylesheet" type="text/css" href="/{file:current:publicUrl}" media="all">
}
}
}
}
在这里使用HMENU因为FILES对象不能提供与通过模板方法相同的继承。但是如果你不需要继承,你可以这样做:
lib.additionalStyles = FILES
lib.additionalStyles {
references {
# To use media from current page only
table = pages
uid.data = field:uid
fieldName = media
# To add some inheritance if media for current page wasn't set
data = levelmedia: level[, slide]
# depending on level value you can take media from root page,
# from current page, from any level upper in tree, or first
# existing media item starting from current page to root.
# So you can't collect media from all parent pages, only
# from current or one of the parents.
}
renderObj = TEXT
renderObj {
if.value = css
if.equals.data = file:current:extension
dataWrap = <link rel="stylesheet" type="text/css" href="/{file:current:publicUrl}" media="all">
}
}
然后将对象导入headerData:
page.headerData.10 < lib.additionalStyles
或(如果你包括JS)
page.footerData.10 < lib.additionalJS
现在,您可以在页面设置的“资源”选项卡上创建与所需文件的关系。不确定所有版本的Typo3是否允许css和js用于关系,但6.2-8.7确实如此)