Код: Выделить всё
DROP TABLE IF EXISTS `ok_files`;
CREATE TABLE `ok_files` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`object_id` int(11) NOT NULL DEFAULT '0',
`filename` varchar(255) NOT NULL DEFAULT '',
`type` enum('product','blog', 'brand','page','order') NOT NULL,
`position` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
2. добавить в папку /api - Files.php (в архиве)
3. добавляем класс в api/Okay.php
Код: Выделить всё
'files' => 'Files',
4. добавляем в config/config.php
Код: Выделить всё
;Директория файлов
cms_files_dir = files/files/;
5.ставим права 777 на папку
6. добавить в нужный контролер админки (/backend/core/BrandAdmin.php, /backend/core/ProductAdmin.php, /backend/core/PageAdmin.php) код для POST запроса
ищем примерно 54 строка
Код: Выделить всё
$brand = $this->brands->get_brand($brand->id);
ниже вставим
Код: Выделить всё
//прайс
$files = array();
$files = (array)$this->request->post('files');
// Удаление файлов
$current_files = $this->files->get_files(array('object_id'=>$brand->id,'type'=>'brand'));
foreach($current_files as $file)
if(!in_array($file->id, $files['id']))
$this->files->delete_file($file->id);
// Порядок файлов
if($files = $this->request->post('files')){
$i=0;
foreach($files['id'] as $k=>$id)
{
$this->files->update_file($id, array('name'=>$files['name'][$k],'position'=>$i));
$i++;
}
}
// Загрузка файлов
if($files = $this->request->files('files')){
for($i=0; $i<count($files['name']); $i++)
{
if ($file_name = $this->files->upload_file($files['tmp_name'][$i], $files['name'][$i])){
$this->files->add_file($brand->id, 'brand', $file_name);
}
else {
$this->design->assign('error', 'error uploading file');
}
}
}
//прайс конец
ниже ищем
Код: Выделить всё
$this->design->assign('brand', $brand);
и выше вставим
Код: Выделить всё
$files = array();
$files = $this->files->get_files(array('object_id'=>$brand->id,'type'=>'brand'));
$this->design->assign('cms_files', $files);
7.
вдизайн шаблон backend/../brand.tpl
в самый конец вставим
Код: Выделить всё
<script>
$(window).on("load", function() {
// Удаление товара
$(document).on( "click", "a.delete", function() {
$(this).closest("div.row").fadeOut(200, function() { $(this).remove(); });
return false;
});
});
</script>
в удобном месте вставим (примерно 200 строка)
Код: Выделить всё
<!-- прайс лист -->
<div class="col-lg-12 col-md-12">
<div class="boxed match fn_toggle_wrap tabs">
<h2>Прайс лист: </h2>
{if $cms_files|count>0}
<div id=list class="sortable files_brand">
{foreach $cms_files as $file}
<div class="row okay_list" style="margin: 8px 0;">
<div class="okay_list_boding1 okay_list_drag move_zone">
{include file='svg_icon.tpl' svgId='drag_vertical'}
</div>
<div class="name cell okay_list_boding1 okay_list_related_name1">
<input type=text name="files[name][]" value="{if $file->name}{$file->name}{else}{$brand->name|escape}.xls {/if}" placeholder="напиши">
</div>
<div class="name cell okay_list_boding1 okay_list_related_name1">
<input type=hidden name="files[id][]" value="{$file->id}">
<a target="_blank" href="{$config->cms_files_dir}{$file->filename}">
{$file->filename}
</a>
</div>
<div class="okay_list_boding1">
<a href="#" class="delete">{include file='svg_icon.tpl' svgId='delete'}</a>
</div>
<div class="clear"></div>
</div>
{/foreach}
</div>
{else}
Нет файлов
{/if}
<br/>
<input class='upload_file' name=files[] type=file multiple accept='pdf/xls/doc/xlsx'>
</div>
</div>
<!-- Прайс (The End)-->
8. view/brandsview.php
после
Код: Выделить всё
$brands = $this->brands->get_brands(array('visible_brand'=>1));
вставим
Код: Выделить всё
$files = $this->files->get_files(array('object_id'=>$brand->id,'type'=>'brand'));
$this->design->assign('cms_files', $files);
в файле дизайна сайта вставим отображение:
Код: Выделить всё
{if $cms_files}
<h2>Файлы</h2>
{foreach $cms_files as $file}
<a href="{$config->cms_files_dir}{$file->filename}">
{if $file->name}{$file->name}{else}{$file->filename}{/if}
</a>
{/foreach}
{/if}
под 2.3.2