I use frontend form to upload files into table tl_news. Then I use news FE modul with news_full template to see files in FE. But on Contao 3.5.25 they disappear, but they come back if I repeat a choice in backend. Where is the problem?
I use frontend form to upload files into table tl_news. Then I use news FE modul with news_full template to see files in FE. But on Contao 3.5.25 they disappear, but they come back if I repeat a choice in backend. Where is the problem?
Best is always to have the latest Contao version installed when asking for help. You can easily update with [easyupdate3].
Make sure, that the field tl_news.singleSRC contains a UUID which points to a file dataset in tl_files with the same UUID in tl_files.uuid.
Maybe you have to use a HOOK e.g. https://docs.contao.org/books/api/ex...eFormData.html to store the correct datasets to the DB.
You can use the public method addResource() from the DBAFS (database assisted file system) class to accomplish this.
If you will not do this at all, you maybe can modify your output template to manage the output of files which do not contain a uuid in field tl_news.singleSRC. But this will be bad practice and you will not profit from DBAFS for this files - e.g. you can not rename, or move such a file with filemanager anymore.PHP Code:
\DBAFS::addResource(...);
Check your template variables by putting this into your template.
PHP Code:
<?php
$this->showTemplateVars();
?>
Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
Amazon wishlist
Is there an example how to get tstamp and uuid if we use forms to store data into tl_news from frontend?
Tnx
This is done automaticaly if you use the upload field in formgenerator. So you will find examples in the core.
Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
Amazon wishlist
I use upload field but obviously something goes wrong. Could be a problem with name....I called her "enclosure"?
This is not true. The form generator will always save the path to the file, not UUIDs.
You can use store_uuid to automatically store the UUID though.
Oh, yes, you're right. I only looked into tl_files where I found the uuid.
But in my target table "files" only the path of the folder is saved into "files.files" ("files/files-test" - same field-type as tl_files.uuid). With your store_uuid 1.0.1 and also without it. What am I doing wrong here?
Last edited by Andreas; 09/04/2017 at 11:11.
Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
Amazon wishlist
This table has no DCA. It's beside Contao.
Code:CREATE TABLE `files` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `tstamp` INT(10) UNSIGNED NOT NULL DEFAULT '0', `files` BINARY(16) NULL DEFAULT NULL, PRIMARY KEY (`id`) ) COLLATE='utf8_general_ci' ENGINE=MyISAM ROW_FORMAT=DYNAMIC AUTO_INCREMENT=9 ;
Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
Amazon wishlist
That's why store_uuid is not working. It needs the DCA information.
Ah, ok. If I save to tl_content.singleSRC it works. But shouldn't it also work in new tables without "tl_"?
Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
Amazon wishlist
And why only the path without the filename gets saved (without your extension)? Is this a Contao bug? It saves
"files/files-test"
instead
"files/files-test/myImg.jpg"
Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
Amazon wishlist
As I said, the extension (currently) needs the DCA info for the target table in order to determine whether or not to save the file as an UUID instead of the path. Forcing it to UUID would be an additional feature that I could implement.
As mentioned on IRC: are you still using your BINARY(16) field for that? If yes - that field cannot hold long path names.
Yes, thank you, it was the wrong field configuration "files/files-test" was coincidentally exact 16 chars long.
No problem, we can use a DCA for "tl_myfiles" if we only would know this fact. But adding this feature also would be great so one can use tables without "tl_".
Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
Amazon wishlist
I solved my problem with store_uuid, and now I have secound problem with tstamp...how to store correct date...I always get 1.1.1970 .
UPS...i did't, with insert tag {{date:U}}.
You get the timestamp with time().
PHP Code:
echo time();
Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
Amazon wishlist
Bookmarks