I want to give a file a unique name, that is easy identifiable, e.g. filename-{aid}.csv, where {aid} is the id when content is saved to the database. The read_dataXX function is working properly and all the values go to the file, so "aid" is known, but what do I have to do to make it part of the file name?
This returns only filename-.csv, but
returns nutzertermin-["21"].csv. 21 is the correct aid, but I don't want the brackets and the quotes in the name. Any ideas?
TIA
filename-{var:read_data4.Data4.aid}.csv
This returns only filename-.csv, but
filename-{var:read_data4.[n].Data4.aid}.csv
returns nutzertermin-["21"].csv. 21 is the correct aid, but I don't want the brackets and the quotes in the name. Any ideas?
TIA
Hi,
Please set the your "read data" "select type" to "First matching" in order to get a single record then use:
Best regards
Please set the your "read data" "select type" to "First matching" in order to get a single record then use:
{var:read_data4.Data4.aid}
Best regards
Thanks for your advice. The filename is now as I wanted, but the CSV is now completely empty. I tried several settings myself, but no solution. The debugger shows, that the data is there in an array, but the data is not written to the file.
These were my prior settings for reading data:
Order fields = aid/desc
Select type = All matching records instead of First matching record
Paging for multiple results = Disabled
Page limit = 1
Offset = 0
Fields to retrieve = All needed fields were entered
Settings for writing CSV:
Data provider = {var:read_data4.[n].Data4}
Disabled header titles
Filename = nutzertermin-{var:read_data4.Data4.aid}.csv <- As told
So I have the choice, filled CSV and not the filename I want or the filename I want, but empty CSV.π
Perhaps I don't get the concept behind reading data and writing the file. So I need a little more assistance on this matter.
TIA
These were my prior settings for reading data:
Order fields = aid/desc
Select type = All matching records instead of First matching record
Paging for multiple results = Disabled
Page limit = 1
Offset = 0
Fields to retrieve = All needed fields were entered
Settings for writing CSV:
Data provider = {var:read_data4.[n].Data4}
Disabled header titles
Filename = nutzertermin-{var:read_data4.Data4.aid}.csv <- As told
So I have the choice, filled CSV and not the filename I want or the filename I want, but empty CSV.π
Perhaps I don't get the concept behind reading data and writing the file. So I need a little more assistance on this matter.
TIA
I found a solution, well more a dirty hack. Open / libraries / cegcore2 / admin / extensions / chronofc / functions / csv / csv_output.php and insert after line 56
So the special chars are removed from nutzertermin-{var:read_data4.[n].Data4.aid}.csv
Don't expect elegant code from me.π
$file_path = str_replace('[', '', $file_path);
$file_path = str_replace(']', '', $file_path);
$file_path = str_replace('"', '', $file_path);
So the special chars are removed from nutzertermin-{var:read_data4.[n].Data4.aid}.csv
Don't expect elegant code from me.π
Hi joachim,
Thank you for sharing the codeπ
it depends on the syntax used, the file name shortcode should return a string, but the provider should return an array, otherwise there will be problems!
You can test nutzertermin-{var:read_data4.Data4.aid}.csv in a custom code action to check if it returns the correct filename value.
Best regards
Thank you for sharing the codeπ
it depends on the syntax used, the file name shortcode should return a string, but the provider should return an array, otherwise there will be problems!
You can test nutzertermin-{var:read_data4.Data4.aid}.csv in a custom code action to check if it returns the correct filename value.
Best regards
This topic is locked and no more replies can be posted.