Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
What's the correct way to display file information?
Howdy!
I’m developing a site that has PDF versions of most articles. In my Write tab, I have a custom field called file_id where the user can add the numeric ID of the file uploaded using the Files tab. But I’m having a dickens of a time getting the file info to render in article context.
Here’s what I have in my article form:
<txp:file_download id='<txp:custom_field name="file_id"/>' form="myFileForm" />
But no matter what I do, I get this error when the page is rendered in debug mode:
Tag error: <txp:file_download id=’<txp:custom_field name=“file_id”/>’ form=“myFileForm”/> -> Textpattern Notice: File tags cannot be used outside a file context on line 2189
textpattern/lib/txplib_misc.php:2189 trigger_error()
textpattern/publish/taghandlers.php:3373 assert_file()
textpattern/publish.php:1106 file_download()
textpattern/publish.php:1028 processTags()
textpattern/publish.php:786 parse()
textpattern/publish.php:903 doArticles()
textpattern/publish.php:893 parseArticles()
textpattern/publish.php:1106 article_custom()
textpattern/publish.php:1041 processTags()
textpattern/publish.php:506 parse()
I know I’m doing something wrong, but it’s not obvious to me what. The tag reference seems to indicate that file_download is the correct tag to establish file context, and Textpattern Solutions doesn’t give any examples.
Last edited by johnstephens (2009-11-06 16:33:41)
Offline
Re: What's the correct way to display file information?
johnstephens wrote:
The tag reference seems to indicate that file_download is the correct tag to establish file context
Hmmm, then we should probably change the tag reference to make it more accurate :-)
Couple of ways you can approach it: add file_download_list around your file_download_whataver tags to ensure you’re in a file list context, or use the file_download_link tag to grab the URL of the file and build your own anchor tag.
If you’re using other file_download_whatever tags in your form you’ll probably want to use <txp:file_download_list id='<txp:custom_field name="file_id"/>'>
. All tags inside the form/container can then be used as ‘single’ tags and will output the info for the given file ID.
It does seem odd to have to make a “list of 1 file” in order to trigger list context, but that’s the way it works :-\
Last edited by Bloke (2009-11-06 16:47:45)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: What's the correct way to display file information?
Thanks, Stef— it worked! A list of one is okay by me!
Offline