我正在接受最新的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期间如何映射图像
答案 0 :(得分:2)
singleSRC
中的tl_news
字段(例如tl_content
和tl_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;