Another way to do that, dirty but without editing an extension template:
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">
}
}
}
}
Using HMENU here because FILES object can't provide same inheritance as including through template method. But if you don't need inheritance you can do this:
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">
}
}
Then import object to headerData:
page.headerData.10 < lib.additionalStyles
or (if you are including JS)
page.footerData.10 < lib.additionalJS
Now you can just create a relations to needed files on Resources tab in page settings. Not sure if all versions of Typo3 allows css and js for relations, but 6.2-8.7 does)