0

I have a Query tag to output Matrix data for various entries. One of the Matrix fields is an Assets field, which is linked to files stored on Amazon S3.

Within the Assets database, this fields data does not hold the full Amazon S3 path. This path seems to be stored within a JSON encoded array in the field Settings in exp_assets_sources.

So therefore I am stuck as to how to get the full S3 path within my Query to link to the Amazon file. Anyone know?

Thanks

1

Answered my own question...

Enabling PHP and then using json_decode of course:

{exp:query
    sql="SELECT
            md.*,
            ct.title AS title,
            ct.url_title AS url_title,
            af.file_id,
            aso.settings AS settings
        FROM exp_matrix_data md
        LEFT JOIN exp_channel_titles ct ON md.entry_id = ct.entry_id
        LEFT JOIN exp_assets_selections ass ON md.row_id = ass.row_id
        LEFT JOIN exp_assets_files af ON ass.file_id = af.file_id
        LEFT JOIN exp_assets_sources aso ON af.source_id = aso.source_id
        WHERE md.col_id_5 = 'xxxxxx'
}

<?php
$settings = json_decode('{settings}');
$url_prefix = $settings->url_prefix;
?>

<?php echo $url_prefix;?>
| improve this answer | |
  • Laurence, I'd look into the subfolder settings as well - as of Assets 2.1 it's possible to use a subfolder of S3 as your source, so you would probably add $settings->subfolder there as well. – Andris Sevcenko Apr 12 '13 at 5:03
  • Thanks Andris, yes I realised that once the customer started creating sub folders! :) – Laurence Cope May 8 '13 at 22:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.