Hi,
jemand eine Idee wie es möglich ist einen eigenen Download mit der selben Funktion wie "Download" zu basteln?
Möchte gern ein eigenes Download-Element basteln, bekomme aber den Download nicht gestartet.
Nicolas
Hi,
jemand eine Idee wie es möglich ist einen eigenen Download mit der selben Funktion wie "Download" zu basteln?
Möchte gern ein eigenes Download-Element basteln, bekomme aber den Download nicht gestartet.
Nicolas
Was willst du da basteln, bzw was stört dich am vorhandenen Download-Inhaltselement?
Ansonsten ist es nicht weiter schwierig, eine Datei so auszuliefern wie ein Downloadelement. Kannst du dir in system/modules/core/elements/ContentDownload.php in der Funktion generate() anschauen.
Ich hatte das mal für ContentDownloads
wo ich eine dynamische Downloadliste gebastelt hab.
vielleicht hilft'sPHP-Code:
$objFiles = \FilesModel::findBy('~~~je nachdem, wie deine Dateiauswahl aussehen soll ~~~');
if ($objFiles) {
$files_uuids = $objFiles->fetchEach('uuid');
// generate new ContentModel object
$objContentModel = new \ContentModel();
// set the files and other basic properties
$objContentModel->multiSRC = serialize($files_uuids);
$objContentModel->sortBy = 'date_desc';
$objContentModel->useHomeDir = false;
$objContentModel->metaIgnore = false;
$objContentModel->type = 'downloads';
// generate new ContentElement and generate HTML
$ce_downloads = new \ContentDownloads($objContentModel);
echo $ce_downloads->generate();
}
Habe mir mit RockSolid Custom Elements ein eigenenes Download-Element mit Vorschaufunktion für das downloadbare Bild gebastelt
Hierzu habe ich das Standard Downloadverhalten von Contao benötigt.
Die Lösung meines Vorhabens brachte schlussendlich die Erweiterung: contao-inserttag_download von heimrichhannot!
Danke für eure Hilfe!
Mit
Code:\FilesModel::findByUuid($this->feldname_von_rsce as $uuid);
und dem inserttag vom Modul
geht das.''' {{download::b93b1802-ae7a-11e3-9888-6c626d57edad::My Portfolio::CSS-Class::CSS-ID}} - return den download element with linktext set to "my portfolio" and a given css classname and id {{download_link::b93b1802-ae7a-11e3-9888-6c626d57edad}} - return the download link {{download_size::b93b1802-ae7a-11e3-9888-6c626d57edad}} - return the download filesize '''
Geändert von foil (10.08.2017 um 21:30 Uhr)
Eine schöne Lösung wäre auch mit Controller::sendFileToBrowser zu arbeiten:
PHP-Code:
<?php
if($item->file):
//$filePath = \FilesModel::findById($item->file)->path;
$filePath = "/files/pathToFile.pdf";
if (\Input::get('file'))
\Contao\Controller::sendFileToBrowser(\Input::get('file'));
?>
<a href="<?php echo Environment::get('uri') ."?file=". $filePath; ?>">
Download
</a>
<?php endif; ?>
Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
Lesezeichen