Figured this would be the most useful part of file grid from a front-end dev POV…
But this:
{grid_field}
{grid_field:file}
{extension}
{/grid_field:file}
{/grid_field}
Results in the file path being printed, followed by the extension. In other words, the file metadata tag pair that ordinary Grid has, doesn’t work here. Tried without the tag pair, and the extension (and any other file-field variable) doesn’t parse.
Anyone got any workarounds that don’t involve changing the whole thing back to an ordinary Grid field?
You shouldn’t need to work around- I just tested on the latest and it worked as expected. My file grid field is named afg (I can’t recall why). My test looked like:
{exp:channel:entries entry_id="18"}
<h3>{title}</h3>
{afg}
{afg:file}
{url} - {extension}
{/afg:file}
{/afg}
{/exp:channel:entries}
Output was
ok, two cats!
<img src="https://e531:8890/themes/user/site/default/asset/img/blog/bad_fur_day.jpg" alt="" /> - jpg
<img src="https://e531:8890/themes/user/site/default/asset/img/blog/avatar_tree_hugger_color.png" alt="" /> - png
That said- your template code looks good to me, assuming ‘grid_field’ is the name of your grid field.
If that’s correct, I’d start with a simple test, similar to mine. And triple check the names. Still no lucky, try disabling extensions for a quick test.
But it should work. Basically code it like you would a file field in a grid, just making sure to use ‘file’ as the shortname of the file column. Though again- your basic code looks good from here.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.