如何在Contao新闻扩展中映射图像?

时间:2017-10-03 10:39:19

标签: contao

我正在接受最新的Contao 4的新闻报道。

Can anyone please explain how the image files are related to tl_news table ?
Currently for my migration I have imagepath and imagename for the respective image.

When I add an image to a news in contao through backend. The following fields get updated in database. 

addImage => 1,

singleSRC => f52a3871946211e782662e3e7a222c66

But when I search singleSRC in tl_files.uuid , it doesn't show any records.

请帮助我找到在迁移到Contao 4期间如何映射图像

1 个答案:

答案 0 :(得分:2)

singleSRC中的tl_news字段(例如tl_contenttl_calendar_events)是二进制字段,其中包含与之相关的UUID tl_files.uuid字段。

我不知道你是如何实现新闻迁移脚本的。但是在Contao框架中,这就是从singleSRC获取文件路径的方法,例如:

// $objNews is a \Contao\NewsModel object
$objFile = \Contao\FilesModel::findByUuid($objNews->singleSRC);
$strPath = $objFile->path;

这就是你如何将它添加回其他地方的新新闻:

// $strPath contains the relative path of the file on the other installation
$objFile = \Contao\Dbafs::addResource($strPath);
$objNews->singleSRC = $objFile->uuid;