1

Add an extra field for fileupload. But the data getting in template is a set of special characters. How to get the original path?

My code:

$GLOBALS['TL_DCA']['tl_news']['fields']['image'] = array
(
    'label'                   => &$GLOBALS['TL_LANG']['tl_news']['quoteperson_image'],
    'exclude'                 => true,
    'filter'                  => true,
    'inputType'               => 'fileTree',
    'eval'                    => array('tl_class'  => 'clr','files' => true,'fieldType' =>'checkbox',),
     'sql'                    => "blob NULL",
);
David Oliver
  • 2,424
  • 1
  • 24
  • 37
Aswathy S
  • 729
  • 1
  • 12
  • 41

1 Answers1

4

The data returned by the fileTree widget is a binary UUID. In order to get the original path you can do the following for example:

$objFile = \Contao\FilesModel::findByUuid($uuid);
$strPath = $objFile->path;
fritzmg
  • 2,494
  • 3
  • 21
  • 51
  • Fritzmg thank you. Its working. I think the PHP operations done in template file is not a good practice. Then where can we do these manipulations? Did we need to extend news listing module also? – Aswathy S Sep 26 '17 at 04:31
  • 1
    I think it's fine to do that in the template. But in case of news you can use the `parseArticles` hook for that. That provides a clean way to inject the appropriate variables into your news template. – fritzmg Sep 26 '17 at 07:52