Skip to content

Instantly share code, notes, and snippets.

@gabrielRamaker
Created May 10, 2016 08:00
Show Gist options
  • Save gabrielRamaker/a4df92dfcbba88a771d8d4522f6c5b34 to your computer and use it in GitHub Desktop.
Save gabrielRamaker/a4df92dfcbba88a771d8d4522f6c5b34 to your computer and use it in GitHub Desktop.
Typoscript to modify typo3 filelinks to add icon and filesize without userFunc
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">&nbsp;-&nbsp;|</span>
}
}
}
}
lib.parseFunc_RTE.tags.link < lib.parseFunc.tags.link
@Megafry
Copy link

Megafry commented Sep 23, 2020

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">&nbsp;-&nbsp;|</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