Forums

Creating seperate download links from CF6 Multi-file-select upload

Marty79 14 Aug, 2018
Hi,

I am trying to explode or split a Multi-file-select comma separated string from CF6 into CC6 table with the download links and their belonging link paths. Is this possible?

Up till now I mixed a lot of views and components with straight php or shortcodes with poor results. The URL: {path/url:}/uploads/{var:read_article.Article.file20} only gets one correct but double quoted filepath. The read_article function does not seem to respond to {data.split:string} nor does php explode. Also {data:[0].file20} gives nothing.

Is there, by any chance, more information to this matter? Or another example concerning Multi-file-select upload in CF6 to Download function in CC6? Also tried the latter from Files->Download, but how to individually connect to comma separated values? Just a pointer in the right direction would be greatly appreciated.

Thanks,
Marty
GreyHead 15 Aug, 2018
Hi Marty,

Please try adding a Debugger action, that will show you the data that is available when the form submits. I'm pretty sure that the file data is returned as an array. If you are seeing a comma separated list maybe you have a Handle Arrays action there somewhere?

Bob
Marty79 16 Aug, 2018
Hi Bob,

The ChronoForms6 Debugger shows an array for the Event and the Upload, but the Save Data shows: [file20] => ["20180816073812_jvb-oppo-logo.png","20180816073812_logo.png","20180816073812_qinas-logo.png"]

For some reason ChronoConnectivity6 does not allow me to Read Data in a Function Where conditions get those specific array keys. I tried dozens of shortcodes and php actions. Is this the right way to create the correct download links in the table?

Thanks,

Martijn
GreyHead 16 Aug, 2018
Hi Martijn,

I am not clear exactly what you are doing here.

It looks as though the file upload data - or part of it - is being converted from an array to a string. If ChronoForms is doing this automatically then you may need to unseparate that before saving - use a PHP code action with explode().

What is actually being saved in the table and what do you want to be saved?

Bob
Marty79 16 Aug, 2018
Hi Bob,

The ChronoForms6 multi-file table saves: ["20180813144741_10us33q.jpg","20180813144741_avatar-720.png","20180813144741_barcode-image.jpg"]

ChronoConnectivity6 shows exactly this when using {var:articles_list.row.Article.file20}

I want CC6 to show the three filenames with download links. Where do I put the explode function?

Thanks,

Martijn
GreyHead 16 Aug, 2018
Hi Martijn,

I'm not very experienced with CCv6 :-( In CCv5 I would have used the PHP box to read that value, explode it into an array, wrap the values with the <a> link HTML, then implode it back to an array of links.

Bob
Marty79 17 Aug, 2018
Hi Bob,

I was hoping for a more integrated solution, but here is a possible PHP Function:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('file20')));
$query->from($db->quoteName('#__chronoforms_data_direct-contact'));
$query->where($db->quoteName('aid')." = ".'12'); // <- becomes $aid
$db->setQuery($query);
$column= $db->loadColumn(0);
//print_r($column);
$column[0] = trim(column[0], ' ');
$column[0] = str_replace('"', '', $column[0]);
$columnBits = explode(",", $column[0]);
//echo "$column[0]<br />";
echo "$columnBits[0]<br />";
echo "$columnBits[1]<br />";
echo "$columnBits[2]";
The function executes, but how do I make this work within ChronoConnectivity6 Link View URL Parameters while passing the (U)ID like {path/url:}/uploads/{var:articles_list.row.Article.aid} ? Or do I need to create another Function to retrieve the PHP Function? Mixing up shortcodes and PHP is not possible, is it?

Thanks,

Martijn
Marty79 22 Aug, 2018
Hi Bob,

Still not getting it done... How to use this PHP Function within a CC6 View?

Function shortcodes show nothing and PHP snippets in Read Data all fail with me.

There must be a simpler way to subdivide multifile uploads into linked filenames.

Anyone?

Thanks,

Martijn
This topic is locked and no more replies can be posted.