]> _ Git - pmi.git/commitdiff
wait #4054 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 7 Dec 2020 13:31:11 +0000 (14:31 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 7 Dec 2020 13:31:11 +0000 (14:31 +0100)
app/Models/Product.php
resources/views/pages/product-detail.blade.php

index 68714a5f03137a9cde99577eea73ccfd07319ba5..22f6d3c61ddd3728494fac251854fd73799b54ee 100644 (file)
@@ -259,14 +259,15 @@ class Product extends CubistMagicPageModel
          * __('Programme')
          * __('Documentation')
          */
-        $typedocs = ['odt', 'doc', 'docx', 'pdf'];
+
+        $forceDownload = ['software', 'cad'];
         $res = [];
         foreach ($this->_documents as $fieldName => $label) {
             foreach ($this->getMediaInField($this->$fieldName) as $media) {
                 /** @var $media Media */
                 $e = explode('/', $media->getUrl());
                 $fname = array_pop($e);
-                $res[] = ['media' => $media, 'label' => $media->getCustomProperty('alt') ?: $fname, 'tooltip' => __($label), 'type' => $fieldName];
+                $res[] = ['media' => $media, 'label' => $media->getCustomProperty('alt') ?: $fname, 'tooltip' => __($label), 'type' => $fieldName, 'forceDownload' => in_array($fieldName, $forceDownload)?$fname:false];
             }
         }
 
index a3c59512b4179fd72dd34ae3462bc87b730eb0a5..98efe61920818f4429e8428d858cd20f028d56a8 100644 (file)
                     <ul>
                         @foreach($product->getEntity()->getDocuments() as $document)
                             <li>
-                                <a href="{{ $document['media']->getUrl() }}" target="_blank"
+                                <a href="{{ $document['media']->getUrl() }}"
+                                   @if($document['forceDownload'])
+                                   download="{{$document['forceDownload']}}"
+                                   @else
+                                   target="_blank"
+                                   @endif
                                    data-tooltip="{{$document['tooltip']}}"
                                    class="inline-flex items-center text-grey-dark hover:text-primary">
                                     <img class="mr-4 mb-2"