Zitat von
valentin_
Da gibt es dann wohl Probleme, wenn die Datei direkt aus der localconfig kommt.
Habe nun zwei Callbacks eingefügt, damit klappt es:
PHP-Code:
public function saveFile($value) {
if (version_compare(VERSION,'3.2','>=')) {
$uuid = String::binToUuid($value);
$objFile = FilesModel::findByUuid($uuid);
$value = $objFile->path;
}
return $value;
}
public function getFile($value) {
if (version_compare(VERSION,'3.2','>=')) {
$objFile = FilesModel::findByPath($value);
$value = $objFile->uuid;
}
return $value;
}
Hallo Valentin,
bin auch gerade an meinem ersten Modul bei und speicher eine Datei ab. Beim Auslesen erhalte ich als Pfad 'cQ���>�t>('.
Würde nun gerne deiner Lösung folgen und frage mich, wo genau die Callbacks eingefügt werden müssen.
Direkt in die tl_firstmodule.php unter /dca?
Danke schon mal.
/Wolfram
Nachtrag:
Es soll nur ein einzelnes Bild in der DB gespeichert werden. Hatte folgenden Code
PHP-Code:
'logoPath' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_firstmodule']['logoPath'],
'inputType' => 'fileTree',
'exclude' => true,
'eval' => array(
'mandatory'=>true,
'files' => true,
'filesOnly' => true,
'extensions' => 'png,jpg,gif',
'fieldType' => 'radio',
'tl_class' => 'clr'
),
'sql' => "varchar(255) NOT NULL default ''" //"blob NULL"
)
Wenn ich "blob NULL" nehme, bekomme ich 'cQ���>�t>(' als Pfad geliefert. Nehme ich stattdessen "varchar(255) NOT NULL default ''" steht in der Datenbank 'cQ' und das Bild wird beim Bearbeiten des Datensatzes im Backend auch nicht mehr angezeigt
Hab's hinbekommen.
Danke für die Inspiration
tl_firstmodule.php
PHP-Code:
'logoPath' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_firstmodule']['logoPath'],
'inputType' => 'fileTree',
'exclude' => true,
'eval' => array(
'mandatory'=>true,
'files' => true,
'filesOnly' => true,
'extensions' => 'png,jpg,gif',
'fieldType' => 'radio',
'tl_class' => 'clr'
),
'save_callback' => array
(
array('tl_firstmodule', 'saveFile')
),
'load_callback' => array
(
array('tl_firstmodule', 'loadFile')
),
'sql' => "varchar(255) NOT NULL default ''" //"blob NULL"
)
//...
class tl_firstmodule extends Backend
{
public function saveFile($value) {
if (version_compare(VERSION,'3.2','>=')) {
$uuid = String::binToUuid($value);
$objFile = FilesModel::findByUuid($uuid);
$value = $objFile->path;
}
return $value;
}
public function loadFile($value) {
if (version_compare(VERSION,'3.2','>=')) {
$objFile = FilesModel::findByPath($value);
$value = $objFile->uuid;
}
return $value;
}
}
Lesezeichen