1

I am doing a newsmigration to latest 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.

Please help me to find how the images can be mapped during migration to Contao 4

ebin mathew
  • 33
  • 1
  • 4

1 Answers1

2

The singleSRC field in tl_news (and also tl_content and tl_calendar_events for example) is a binary field containing an UUID that relates to the tl_files.uuid field.

I do not know how exactly you implemented your news migration script. But within the Contao framework, this is how you get the path to a file from singleSRC for example:

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

And this is how you would add it back to the new news entry somewhere else:

// $strPath contains the relative path of the file on the other installation
$objFile = \Contao\Dbafs::addResource($strPath);
$objNews->singleSRC = $objFile->uuid;
fritzmg
  • 2,494
  • 3
  • 21
  • 51