增加每个类别的最大缩略图数

时间:2015-03-24 12:16:37

标签: php model-view-controller override prestashop prestashop-1.6

在类别管理AdminCategories中,我只能上传3个缩略图。

我想增加允许的最大数量。另外我还想增加最大文件大小。

我在renderForm()

中的AdminCategoriesController.php方法中找不到解决方案

1 个答案:

答案 0 :(得分:1)

在classes / helper / HelperForm.php

public function generate ()
{
(...)
case 'file':
                            $uploader = new HelperUploader();
                            $uploader->setId(isset($params['id'])?$params['id']:null);
                            $uploader->setName($params['name']);
                            $uploader->setUrl(isset($params['url'])?$params['url']:null);
                            $uploader->setMultiple(isset($params['multiple'])?$params['multiple']:false);
                            $uploader->setUseAjax(isset($params['ajax'])?$params['ajax']:false);
                            $uploader->setMaxFiles(isset($params['max_files'])?$params['max_files']:null);

                            if (isset($params['files']) && $params['files'])
                                $uploader->setFiles($params['files']);
                            elseif (isset($params['image']) && $params['image']) // Use for retrocompatibility                          
                                $uploader->setFiles(array(
                                    0 => array(
                                    'type'       => HelperUploader::TYPE_IMAGE,
                                    'image'      => isset($params['image'])?$params['image']:null,
                                    'size'       => isset($params['size'])?$params['size']:null,
                                    'delete_url' => isset($params['delete_url'])?$params['delete_url']:null
                                )));

                            if (isset($params['file']) && $params['file']) // Use for retrocompatibility                            
                                $uploader->setFiles(array(
                                    0 => array(
                                    'type'       => HelperUploader::TYPE_FILE,
                                    'size'       => isset($params['size'])?$params['size']:null,
                                    'delete_url' => isset($params['delete_url'])?$params['delete_url']:null,
                                    'download_url' => isset($params['file'])?$params['file']:null
                                )));

                            if (isset($params['thumb']) && $params['thumb']) // Use for retrocompatibility                          
                                $uploader->setFiles(array(
                                    0 => array(
                                    'type'       => HelperUploader::TYPE_IMAGE,
                                    'image'      => isset($params['thumb'])?'<img src="'.$params['thumb'].'" alt="'.(isset($params['title']) ? $params['title'] : '').'" title="'.(isset($params['title']) ? $params['title'] : '').'" />':null,
                                )));

                            $uploader->setTitle(isset($params['title'])?$params['title']:null);
                            $params['file'] = $uploader->render();
                        break;
(...)
}

您可以使用HelperUploader类中的setMaxFiles覆盖此类并设置自定义值。

$uploader->setMaxFiles(isset($params['max_files'])?$params['max_files']:null);