Multiple Image/File Page Attribute

Permalink
Hi,

I need a multiple file attribute for 5.7, I have been toying around with it a little but haven't figured yet how to launch the file manager from the attributes dashboard page.

Adding a single file is easy enough with:
$al = Loader::helper('concrete/asset_library');
        $form = '<div class="ccm-attribute ccm-attribute-image-file">';
        $form .= $al->file('ccm-file-akID-' . $this->attributeKey->getAttributeKeyID(), $this->field('value'), t('Choose File'), $bf);
        $form .= '</div>';
        print $form;


What I would like to do is have a select files button that launches the File Manager and comes back to the Attributes page with an array of files that I can save.

Has anyone else been looking into this or have some thoughts on how to do it.

thanks

pvernaglia
 
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi pvernaglia,

I don't have experience creating custom attributes, but I think I understand what you are trying to do.

In 5.7.4, a file manager multiple selection feature was added by olsgreen. This is the pull request that added the feature -https://github.com/concrete5/concrete5/pull/2055... .

User olsgreen kindly made a commented example showing how it it might be used.
// Wire the trigger to show the file manager dialog
$('#addImageBtn').click(function () {
    // Launch the dialog
    ConcreteFileManager.launchDialog(function (data) {
        // Parse the callback data to get more file detail
        ConcreteFileManager.getFileDetails(data.fID, function(r) {
            // Loop over each file and do whatever you want with it
            for(var i = 0; i < r.files.length; i++) {
                // Do whatever with each file
                console.log(r.files[i]);
                /* Above will output
                {
                    canCopyFile: 1
                    canDeleteFile: 1
                    canEditFile: true

The code above will launch the file manager and using multiple selection should return an array of objects for the selected items (including the fID).