So Mark Hout’s plugin provided some nice flexibility through the use of variable pairs.
Variable Pairs
{[custom_field]}…{/[custom_field]} — When used as a pair the contained code will loop, outputting all the uploaded files.
count — Numeric number of each file
total_results — Total number of files uploaded to the custom field
file_name — Filename of the uploaded file.
file_url — URL to the uploaded file.
file_thumb_name — Filename of the uploaded thumbnail.
file_thumb_url — URL to the uploaded thumbnail.
In particular, is there a way to output the file_url, or file_name of a custom field type of file in EE2?
Why I ask, is that I’m trying to migrate something to EE2 for a client from something that was written for EE 1.6.9 - using Hout’s file plugin, in conjunction with the Happy Worm Audio Player
<?php
// to listen: send pages to index/listen/{entry_id}
//clean file name of .mp3 and replace underscores with spaces
function clean_name($name) {
$bad = array('.mp3', '_');
$good = array('',' ');
return str_replace($bad, $good, $name);
}
?>
{if segment_2 == 'listen'}
{exp:weblog:entries weblog="shop" entry_id="{segment_3}" limit="1"}
{if:else}
{exp:weblog:entries weblog="shop" order_by="date" limit="1"}
{/if}
[removed]
var playItem = 0;
var myPlayList = [
{mp3_file backspace="1"}
{name: "<?=clean_name('{file_name}')?>", mp3: "{file_url}"},
{/mp3_file}
];
[removed]In my case, this is where Hout’s plugin was super handy.
{mp3_file backspace="1"}
{name: "<?=clean_name('{file_name}')?>", mp3: "{file_url}"},
{/mp3_file}It allowed us to create a page like this:
So, is there a way to loop the entries using just the file custom field? Output the file name? Or the url?