I'm currently writing a plugin that returns a result set comprising channel_titles and channel_data. I have a file field in there, so the columns from channel_data are formatted like {filedir_1}filename.jpg

Now, I figure there must be a way to use this information so that I can call the file field type tags (like {field:size}) or the tag pair (like {field}{path}{/field}) from my template, but I don't have a clue how to do this and I can't find any documentation on it. Can anyone help?

In case this isn't clear, here's an example:

My plugin method

My template

You can see, I'm manually converting that string to the path, and it's ugly as sin. Ideally, I'd like to be able to use that file field type in exactly the same way as it's used in {exp:channel:entries}.

Anyone know how to do this?


I don't know exactly how EE does it, but you can grab the paths based on the filedir # like this: $query = $this->EE->db->query("SELECT url FROM exp_upload_prefs WHERE id='1'");

where id='1' is the filedir_1. So you need to grab that # and use it to grab the url.

  • Yeah, if I'd needed that level of flexibility in the template, I'd have abstracted to a different tag, but ideally I wanted to be able to use the tags in the same way as you do in {exp:channel:entries} because that'd give me access to things like Matrix as well. – Jasper Tandy Jul 19 '13 at 13:10
  • If you grab that upload path in the plugin and use str_replace to replace {filedir_1} then when it returns to the template it'll be the full image with path which is what EE normally does. – Ponder The Web Jul 19 '13 at 14:39

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.