php – TYPO3扩展构建器多个图像上传无法正常工作
作者:互联网
我的目标是使用TYPO3 7.6.2版本中的扩展构建器创建扩展.我从扩展构建器文档创建了Category Product扩展,除上传单个图像外,它工作正常.
但我必须创建功能,将多个图像添加到单个产品,并在前端显示图像轮播.但扩展构建器不适用于文件上载.
我是TYPO3的新手,所以我不明白如何添加多个图像?我读了太多文件,但没有找到完美的解决方案.
我只是想知道如何向产品添加多个图像的过程?
提前致谢!
解决方法:
最后我得到了这个问题的解决方案.
转到您的扩展程序并按照步骤操作 –
> /Classes/Domain/Model/YourModel.php
/**
* yourPictures
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
* @lazy
*/
protected $yourPictures = NULL;
/**
* Constructor
*
* @return AbstractObject
*/
public function __construct() {
// ObjectStorage is needed to reference multiple files to one field
// see also @var before variable and @return before the respective get() method
$this->yourPictures = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
}
/**
* returns yourPictures
*
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
*/
public function getYourPictures() {
return $this->yourPictures;
}
/**
* sets yourPictures
*
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $yourPictures
* @return void
*/
public function setYourPictures($yourPictures) {
$this->yourPictures = $yourPictures;
}
> /Configuration/TCA/YourModel.php
在数组’types’和数组’columns’中添加字段名称添加 –
'your_pictures' => array(
'exclude' => 1,
'label' => 'LLL:EXT:your_ext/Resources/Private/Language/locallang_db.xlf:tx_yourext_domain_model_yourmodel.your_pictures',
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
'yourPictures',
array('minitems'=>0,'maxitems'=>10),
$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
),
),
> /ext_tables.sql
添加my_pictures varchar(255)DEFAULT”NOT NULL,
>要在流体模板中显示 –
<f:for each="{yourDomain.myPictures}" as="pic">
<f:image src="{pic.originalResource.publicUrl}" alt="{pic.originalResource.alternative}" title="{pic.originalResource.title}" ></f:image>
{pic.originalResource.description}
</f:for>
而已 !希望它会帮助某人.
谢谢
标签:typo3,php,typo3-extensions,extension-builder3 来源: https://codeday.me/bug/20190724/1525798.html