【问题标题】:TYPO3: Uploads in backend moduleTYPO3:在后端模块中上传
【发布时间】:2017-03-20 11:01:37
【问题描述】:

我必须在后端实现“图书”管理。每本书都有PDF预览、标题、描述等... BE 用户应该能够通过后端模块上传 PDF 并设置标题、描述等。

创建的书应该可以在插件(或内容元素?)中选择,以便它可以显示在前端。 此外,上传的 PDF 应该只能由特定的 FE 用户群下载。

我不知道如何处理后端的上传部分。除了这个上传示例之外,我在网上没有找到太多信息:https://github.com/helhum/upload_example 这似乎很复杂,我不确定这是否是最适合我的解决方案。

继续我的任务的最佳方式是什么?

【问题讨论】:

  • 是否需要一个自定义和专用的后端模块来管理这些书籍?否则就有可能使用 Web>List 模块使用后端的常规表单处理...
  • 你是对的,但我也必须实现统计......例如下载次数等。所以我认为该模块是必须的

标签: typo3 fluid extbase


【解决方案1】:

使用文件抽象层 (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,

        ...
)

【讨论】:

  • 谢谢 Heinz,我按照您的建议做了并添加了 我的看法,但是当我提交表单:属性路径“pdf.error”的属性映射时出现异常:未找到给定 UID:“4”的文件引用(sys_file_reference)
  • 后端文件上传由TCA完成。为什么以及在哪里使用
  • 我确实在我的扩展的后端模块中添加了表单。我有一个带有“newAction”的“BackendBookController”,所以我在“New.html”文件中添加了表单。我是typo3的新手,我猜这不是正确的方法?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-04-27
相关资源
最近更新 更多