Created
May 10, 2016 08:00
-
-
Save gabrielRamaker/a4df92dfcbba88a771d8d4522f6c5b34 to your computer and use it in GitHub Desktop.
Typoscript to modify typo3 filelinks to add icon and filesize without userFunc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lib.parseFunc.tags.link { | |
stdWrap.wrap { | |
if { | |
value = file | |
equals.cObject = TEXT | |
equals.cObject { | |
data = parameters:allParams | |
split { | |
token = : | |
cObjNum = 1 || 2 | |
1.current = 1 | |
} | |
} | |
} | |
cObject = COA | |
cObject { | |
10 = FILES | |
10 { | |
files.stdWrap.data = parameters:allParams | |
files.stdWrap.split { | |
token.char = 32 | |
cObjNum = 1 |*| 2 |*| 2 | |
1 { | |
current = 1 | |
split { | |
token = : | |
cObjNum = 1 || 2 | |
2.current = 1 | |
} | |
} | |
} | |
renderObj = TEXT | |
renderObj.stdWrap { | |
data = file:current:extension | |
wrap = <span class="ccv-|"></span> | |
} | |
} | |
20 = TEXT | |
20.value = | | |
30 < .10 | |
30.renderObj.stdWrap { | |
data = file:current:size | |
bytes.labels = " | kB| MB| GB" | |
bytes.base = 1000 | |
wrap = <span class="filesize"> - |</span> | |
} | |
} | |
} | |
} | |
lib.parseFunc_RTE.tags.link < lib.parseFunc.tags.link |
You're the kind of crazy every dev should be! Respect to this great work!
For TYPO3 8.7, 9.5, 10.4
lib.parseFunc {
tags.a.typolink {
ATagBeforeWrap = 1
wrap.cObject = FILES
wrap.cObject {
stdWrap.if {
isPositive.data = parameters:href
isPositive.stdWrap.replacement {
10 {
search = t3://file?uid=
replace =
}
}
}
files.stdWrap < lib.parseFunc.tags.a.typolink.wrap.cObject.stdWrap.if.isPositive
renderObj = COA
renderObj {
10 = TEXT
10 {
data = file:current:extension
wrap = <span class="ccv-|"></span>
}
## add splitChar to string
15 = TEXT
15.value = |
20 = TEXT
20 {
data = file:current:size
bytes = 1
bytes.labels = " | kB| MB| GB"
wrap = <span class="filesize"> - |</span>
}
}
}
}
}
lib.parseFunc_RTE.tags.a.typolink.wrap.cObject < lib.parseFunc.tags.a.typolink.wrap.cObject
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prepends a span with a CSS class 'ccv-[FILE EXT]' to the link text and appends a span with class 'filesize' containing the filesize to the link text