2017-03-17 67 views
1

我必須在後端實施「預訂」管理。每本書都有一個PDF預覽,標題,說明等...... BE用戶應該能夠上傳PDF並通過後端模塊設置標題,描述等。TYPO3:在後端模塊中上傳

創建的書應該可以在插件(或內容元素?)中選擇,因此它可以顯示在前端。 此外,上傳的PDF只能由某一組FE用戶下載。

我不知道如何處理後端的上傳部分。在這個上傳示例旁邊,我沒有在網上找到很多信息:https://github.com/helhum/upload_example它看起來很複雜,我不確定它對我來說是否是最好的解決方案。

什麼是繼續我的任務的最佳方式?

+0

是否具有用於管理這些書籍的自定義和專用後端模塊的要求?否則,將有可能使用常規形式處理後端使用Web>列表模塊... –

+0

你是對的,但我必須實現統計,以及..如下載計數等,所以我認爲該模塊是必須 – user6800816

回答

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, 

     ... 
) 
+0

感謝海因茨,我做了你的建議,並添加了我的觀點,但我提交表單時出現此錯誤:Exception while property在屬性路徑上映射「pdf.error」:沒有找到給定UID的文件引用(sys_file_reference):「4」 – user6800816

+0

TCA完成後端的文件上傳。爲什麼和你在哪裏使用? –

+0

我沒有在我的擴展的後端模塊中添加表單。我有一個帶有「newAction」的「BackendBookController」,所以我在「New.html」文件中添加了表單。我是typo3的新手,我想這不是正確的方法? – user6800816