Verwendung: Download-Element für Contao 5 umbauen
Produkt: Custom Elements Contao
Contao-Version: 5.7
Hallo zusammen,
ich habe ein altes Contao 4 RSCE Template das ich gerne auf Contao 5 umbauen möchte.
Hier das alte Teil:
<div class="downloadbox <?php echo $this->size ?> <?php echo $this->class ?>"<?php echo $this->cssID ?>>
<div class="innen">
<div class="stern"></div>
<?php if ($this->download): ?>
<?php $objFile = \FilesModel::findByUuid($this->download);
$file = \Input::get('file', true);
$objFileSize = $this->getReadableSize(filesize($objFile->path));
if ($file != '' && $file == $objFile->path)
{
\Controller::sendFileToBrowser($file);
}
?>
<div class="ueberschrift"><?= $this->ueberschrift ?></div>
<div class="text"><?= $this->text ?></div>
<div class="size">(<?php echo $objFileSize ?>)</div>
<a href="{{env::request}}?file={{file::<?= $this->download ?>}}" title="<?= $this->ueberschrift ?>">Download</a>
<?php endif ?>
</div>
</div>
So weit habe ich es anpassen können, aber die Datei wird nicht an den Browser übergeben und der Pfad /files/ hat einen / davor.
<div class="downloadbox <?php echo $this->size ?> <?php echo $this->class ?>"<?php echo $this->cssID ?>>
<div class="innen">
<div class="stern"></div>
<?php if ($this->download): ?>
<div class="ueberschrift"><?= $this->ueberschrift ?></div>
<div class="text"><?= $this->text ?></div>
<div class="size"></div>
<?php
$objFile = \Contao\FilesModel::findByUuid($this->download);
$file = \Contao\Input::get('file', true);
$objFileSize = $this->getReadableSize(filesize($objFile->path));
if ($file != '' && $file == $objFile->path)
{
\Contao\Controller::sendFileToBrowser($file);
}
echo $objFileSize;
?>
<a href="{{env::request}}?file={{file::<?= $this->download ?>}}" title="<?= $this->ueberschrift ?>">Download</a>
<?php //$this->dumpTemplateVars() ?>
<?php endif; ?>
</div>
</div>
Vielleicht kann mir jemand das Template anpassen.
Vielen Dank schon mal
Markus
Keyboard shortcuts
Generic
| ? | Show this help |
|---|---|
| ESC | Blurs the current field |
Comment Form
| r | Focus the comment reply box |
|---|---|
| ^ + ↩ | Submit the comment |
You can use Command ⌘ instead of Control ^ on Mac

1 Posted by Markus Schindle... on 12 Mar, 2026 11:44 AM
Hier das Element
Support Staff 2 Posted by RockSolid Theme... on 13 Mar, 2026 10:46 AM
Vielen Dank für Ihre Nachricht.
Ihre Frage betrifft Contao im Allgemeinen und hängt nicht direkt mit Ihrem RockSolid Theme zusammen. In unseren Support-Richtlinien weisen wir darauf hin, dass wir leider keinen allgemeinen Support für Contao anbieten können. Dennoch versuchen wir Ihnen, in diesem Fall, im Rahmen unserer Möglichkeiten weiterzuhelfen:
Uns ist nicht bekannt wie ein Link auf
{{env::request}}?file={{file::<?= $this->download ?>}}in Contao 4.13 funktioniert haben könnte.Sie können versuchen direkt auf
{{file::<?= $this->download ?>}}zu verlinkten und dem Link dasdownload-Attribut hinzufügen. Dafür ist allerdings erforderlich, dass die Datei sich in einem veröffentlichten Ordner befindet.Beispiel:
3 Posted by Markus Schindle... on 13 Mar, 2026 12:05 PM
Vielen Dank das Beispiel hat wunderbar funktioniert.