[TYPO3] Splitting for a filename extenision
JoH
info at cybercraft.de
Tue Apr 4 13:18:02 CEST 2006
> Currently I'm working on a project where I must display a filename
> with a specific icon (pdf, word, jpg, etc).
>
> Now I must extract the extension from the filename.
> For example:
>
> Filename: filename.pdf
>
> Typoscript:
> subimage = TEXT
> subimage.field = media
> subimage.split {
> token.char = 46
> cObjNum = 1
> 1.current = 1
> 1.wrap = |
> }
> subimage.wrap = |
>
> return: filename and pdf
>
> Now I get the first part of the split back, and I must get the last
> part.
>
> How can I get the last part?
>
> That was part 1 of the problem.
>
> Now it's also possible to add files with multiple dots, like:
> filename.new.pdf
>
> In this case the above typoscript won't work.
> I know that there is a session variable called: SPLIT_COUNT and with
> that variable I can make a loop and then find the last part of the
> split.
>
> But how can I get the session variable into typoscript?
It's a Register and you can access it by using the stdWrap function data,
which is of type getText.
10 = TEXT
10.data = register:SPLIT_COUNT
But you don't need it here, since split offers you optionSplit properties.
subimage = TEXT
subimage {
field = media
split {
token.char = 46
cObjNum = |*| 1 |*| 2
1 = TEXT
2.current = 1
}
Will produce empty TEXT for every part except the last one which will be
"current" instead.
Not tested.
Joey
--
Wenn man keine Ahnung hat: Einfach mal Fresse halten!
(If you have no clues: simply shut your knob sometimes!)
Dieter Nuhr, German comedian
openBC: http://www.cybercraft.de
More information about the TYPO3-english
mailing list