我必须实施一本" Book"后端的管理。每本书都有PDF预览,标题,描述等...... BE用户应该能够通过后端模块上传PDF并设置标题,描述等。
创建的Book应该可以在插件(或内容元素?)中选择,以便它可以在前端显示。 此外,上传的PDF只能由特定的一组FE用户下载。
我不知道如何处理后端的上传部分。在上传示例旁边,我没有在网上找到太多信息:https://github.com/helhum/upload_example这看起来相当复杂,我不确定它对我来说是否是最好的解决方案。
进行任务的最佳方式是什么?
答案 0 :(得分:2)
使用文件抽象层(FAL)。你不需要后端的例子,但它对前端上传非常有用。
<强>域/型号/ book.php中强>
...
/**
* File (file references)
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
* @lazy
*/
protected $files = NULL;
/**
* Construct
*
*
*/
public function __construct() {
//Do not remove the next line: It would break the functionality
$this->initStorageObjects();
}
/**
* Initializes all ObjectStorage properties
* Do not modify this method!
* It will be rewritten on each save in the extension builder
* You may modify the constructor of this class instead
*
* @return void
*/
protected function initStorageObjects() {
$this->files = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
}
/**
* Set files (file references)
*
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> $files
* @return void
*/
public function setFiles(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $files) {
$this->files = $files;
}
/**
* Get files (file references)
*
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> $files
*/
public function getFiles() {
return $this->files;
}
...
<强> TCA / tx_yourextension_domain_model_book.php 强>
...
'files' => [
'label' => 'LLL:EXT:werkhandkunst/Resources/Private/Language/locallang_db.xlf:file',
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
'files', ['
maxitems' => 25,
],
$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
),
],
...
<强> ext_tables.sql 强>
CREATE TABLE tx_yourextension_domain_model_book (
...
files int(11) unsigned DEFAULT '0' NOT NULL,
...
)