seppzzz / zipable-dataobjects
此模块为DataObjects添加一个链接(按钮),以便将其压缩并即时下载
dev-main
2023-12-03 20:28 UTC
Requires
- silverstripe/cms: ^4.0
- silverstripe/framework: ^4.0
This package is auto-updated.
Last update: 2024-09-03 22:07:58 UTC
README
即时从数据对象创建.zip文件,包括文本文件和图片
要求
- SilverStripe 4(已测试4.11及以上版本)
安装
仅通过composer支持安装
composer require seppzzz/zipable-dataobjects
文档
config.yml
YourDataObject:
extensions:
- seppzzz\ZipableDataObjects\ZipableDataObject
在您的数据对象上
不要更改“Textfields”和“Images”键。
在“Textfields”数组中创建所需数量的文本字段。
使用“Images”数组指向您的图片对象
public function createZipableFields()
{
$fields = [
'Textfields' => [
'Title' => $this->Title,
'Subtitle' => $this->SubTitle,
'Content' => $this->Content
],
'Images' => $this->Images()
];
return $fields;
}
在您的模板中
<% if $getDownloadLink %>
<a href="$getDownloadLink" class="btn btn-primary zipDownloadButton">Download ZIP</a>
<% end_if %>