[TYPO3-german] Fluidtemplate - Dateigrösse ausgeben

Cedric Ziel cedric at cedric-ziel.com
Fri Dec 13 14:23:32 CET 2013


  Hallo Philip.

Gern.

Ja, vhs bietet einige general-purpose ViewHelper an. (Du musst den
Namespace v in dem Template registrieren, in dem Du ihn nutzt.) Du solltest
im Idealfall die Extension direkt von GitHub
ziehen: https://github.com/FluidTYPO3/vhs

Generell läuft das hier so ab: (Ich notiere von innen nach außen)
# 3. Setze eine neue Variable mit dem Namen "handbookFileInKb" auf den
Inhalt des Tags (Also das Ergebnis aller Operationen, die darin
stattgefunden haben
<v:var.set name="handbookFileInKb">
    # 3.) Das Ergebnis von 2.) ist ein float-runden!
    <v:math.round decimals="2">
      # 2.) dividiere die Dateigröße durch 1024 im von Byte in KByte
zu kommen
      <v:math.division b="1024">
       # 1.) Lese die Dateigröße in Byte aus (Wie es funktioniert,
steht im Quelltext des ViewHelpers)
       <v:media.size path="{product.handbookFile}"/>
      </v:math.division>
     </v:math.round>
</v:var.set>

Nun kannst Du {handbookFileInKb} in nachfolgenden Anweisungen nutzen.

Viele Grüße,
Cedric

Zitat von Philipp Holdener <philipp.holdener at me.com>:

> Hallo Cedric
>
> Besten Dank für dein Tipp.
>
>> Mit EXT:vhs (ViewHelper Collection /
>> https://fedext.net/viewhelpers/vhs.html), geht es echt einfach.
>>
>> <f:if condition="{product.handbookFile}">
>>    <v:var.set name="handbookFileInKb">
>>     <v:math.round decimals="2">
>>      <v:math.division b="1024">
>>       <v:media.size path="{product.handbookFile}"/>
>>      </v:math.division>
>>     </v:math.round>
>>    </v:var.set>
>>    <a href="/{product.handbookFile -> v:format.trim(characters: '/')}"
>> target="_blank"
>>       title="Handbuch {product.name} ( {handbookFileInKb ->
>> v:format.trim()}kb )">
>>     <img src="{f:uri.resource(extensionName: 'cziel_onlinefabrik',
path:
>> 'Icons')}/{v:media.extension(file: product.handbookFile)}.jpg"
>>       alt=" ">
>>    </a>
>>   </f:if>
>>
>> Das könntest Du zB als Section irgendwo in ein Partial auslagern.
>
> Ist mein erstes Fluid Projekt. Hab bis anhin nur mit TemplaVoila
> gearbeitet. Kenn mich deshalb noch nicht wirklich damit aus.
>
> Also ich brauch als erstes eine zusätzliche Extension (vhs), korrekt?
>
> Und dann macht das hier das Ganze?
>
> <v:var.set name="handbookFileInKb">
>> <v:math.round decimals="2">
>>       <v:math.division b="1024">
>>        <v:media.size path="{product.handbookFile}"/>
>>       </v:math.division>
>>      </v:math.round>
>>     </v:var.set>
>
> Gruss
> Philipp
>
> _______________________________________________
> TYPO3-german mailing list
>
TYPO3-german at lists.typo3.orghttp://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-german


More information about the TYPO3-german mailing list