isotope / core

Core repository of Isotope eCommerce, an eCommerce extension for Contao Open Source CMS
https://isotopeecommerce.org
136 stars 107 forks source link

Media Manager corrupt: only working for one single image #366

Closed ghost closed 11 years ago

ghost commented 11 years ago

I've got huge problems using the Isotope Media Manager and I fear that it is not my fault. As described in https://www.contao-community.de/showthread.php?p=184944#post184944 I want to offer pdf files for each product. For that I've created an attribute of type "Media Manager" called "files".

None of the following lines work for frontend output:

$arrFiles = deserialize($this->raw["files"]);
foreach ($arrFiles as $file) {
    echo '<a href="' . $file . '" >FileName</a>';
}

echo $this->files;
print_r($this->files);
print_r($arrFiles);

Output trying to display a link to a pdf file:

echo $this->files;
<div class="iso_attribute" id="fmd7_product_15_files_mediumsize"> </div>

echo $this->raw["files"];
<div class="iso_attribute" id="fmd7_product_15_files_mediumsize"> </div>

echo $this->files->generateGallery();
<div class="iso_attribute" id="fmd7_product_15_files_gallery"></div>

Moreover, the pdf file is not shown in the output of print_r($arrFiles) [in the following example I've uploaded two images and one pdf file]

IsotopeGallery Object
(
    [strTemplate:protected] => iso_gallery_default
    [arrData:protected] => Array
        (
            [name] => fmd7_product_15_files
            [product_id] => 15
            [href_reader] => index.php/shop/produktdetails/product/testbuch
        )

    [arrFiles:protected] => Array
        (
            [0] => Array
                (
                    [src] => fluoresce-figures.jpg
                    [alt] => 
                    [link] => 
                    [desc] => 
                    [translate] => 
                    [gallery_size] => width="125" height="94"
                    [gallery] => system/html/fluoresce-figures-ad68aecf.jpg
                    [thumbnail_size] => width="125" height="94"
                    [thumbnail] => system/html/fluoresce-figures-e663ff16.jpg
                    […]
                )

            [1] => Array
                (
                    [src] => fluoresce2-babe4226.jpg
                    [translate] => 
                    [gallery_size] => width="125" height="94"
                    [alt] => 
                    [desc] => 
                    [gallery] => system/html/fluoresce2-babe4226-fd4c14c2.jpg
                    [thumbnail_size] => width="125" height="94"
                    [thumbnail] => system/html/fluoresce2-babe4226-380c5347.jpg
                    […]
                )

        )

It is only possible to output one single image. More than one image as well as other file types don't work.

My configuration should be correct. "pdf" is one of the allowed file types.

I use Contao 2.10.4 and Isotope 1.3.0 rc1.

Thanks and best regards, Janek

--- Originally created by JaiBee on 2012-02-23 13:58:59 (ID 2930)

blairwinans commented 11 years ago

I'm not sure that the default ImageGallery was meant to treat PDFs and images as downloads. If your intent is to use them as downloads, then I would try this gallery type in your attribute setting, as the default one is not meant to handle PDFs. This will treat the uploads as file downloads rather than as images. Maybe this should get added to the core to solve this issue? Or maybe we should get some methods in the IsotopeGallery class to retrieve the raw files?

--- Originally created by winanscreative on 2012-02-23 14:32:53

aschempp commented 11 years ago

there is also an attribute type "downloads" where you can simply select files from the file manager.

--- Originally created by andreas.schempp on 2012-02-23 14:42:49

ghost commented 11 years ago

If the Media Manager is not intended to handle pdf files you should change its description in the attribute settings: "Upload images and other files to the Isotope eCommerce file system. Output is processed trough an IsotopeGallery class."

The great benefit of the "Media Manager" compared to the "Downloads" is the better workflow, because users don't have any contact with the file system.

Thanks Blair Winans, I'm going to try your solution.

--- Originally created by JaiBee on 2012-02-23 14:49:07

ghost commented 11 years ago

Blairs gallery type works like a charm. Thanks a lot!

However, I had to customize the download link:

echo str_replace($this->replaceInsertTags('{{env::request}}') . "?file=", "",  $file['href']);

--- Originally created by JaiBee on 2012-02-23 15:08:29

blairwinans commented 11 years ago

Keep in mind that to have the downloads link URL work securely and properly, I used a custom product class that checked the file in the GET to the array of files in the MediaManager attribute, and then used a modified version of sendFileToBrowser to deliver the file from the isotope directory.

Let me know if you would also like that custom class to do what you need to or if you are all set.

--- Originally created by winanscreative on 2012-02-23 15:15:39