Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-03-19 17:46:43

maruchan
Member
From: Ukiah, California
Registered: 2010-06-12
Posts: 596
Website

File tags cannot be used outside of a file context?

Amazing that I haven’t found much about this error here on the forums:

File tags cannot be used outside of a file context

Here’s the first form:

<txp:if_custom_field name="acclaim-comma-separated-file-id">
<txp:file_download form="acclaim-files-short" />
</txp:if_custom_field>

And here’s the “acclaim-files-short” form:

 <txp:file_download_list limit="3" sort="modified desc" id="<txp:custom_field name="acclaim-comma-separated-file-id"/> "/>
    <a href="<txp:file_download_link />" title="<txp:file_download_name /> -- <txp:file_download_modified format="%c" />">Acclaim (most recent, pdf)</a><br />
  </txp:file_download_list>

Any obvious problems? Haven’t worked with all of these file tags before. Thanks.

Last edited by maruchan (2011-03-19 17:46:52)

Offline

#2 2011-03-19 18:28:00

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: File tags cannot be used outside of a file context?

Try changing this:

<txp:file_download_list limit="3" sort="modified desc" id="<txp:custom_field name="acclaim-comma-separated-file-id"/> "/>

into

 <txp:file_download_list limit="3" sort="modified desc" id='<txp:custom_field name="acclaim-comma-separated-file-id"/>' />

And if that doesn’t work, switch to debug mode and post the tag trace and complete error message.

Offline

#3 2011-03-19 18:36:04

maruchan
Member
From: Ukiah, California
Registered: 2010-06-12
Posts: 596
Website

Re: File tags cannot be used outside of a file context?

Still same error. Here’s the relevant part of the tag trace:

<txp:if_custom_field name="acclaim-comma-separated-file-id">
			[<txp:if_custom_field name="acclaim-comma-separated-file-id">: true]
			<txp:file_download form="acclaim-files-short" />
				Tag error: <txp:file_download form="acclaim-files-short" /> -> Textpattern Notice: File tags cannot be used outside a file context  on line 2305
		</txp:if_custom_field>

I understand why you said that though…I forgot about tags-within-tags.

Tag error: <txp:file_download form="acclaim-files-short" /> ->  Textpattern Notice: File tags cannot be used outside a file context  on line 2305

textpattern/lib/txplib_misc.php:2305 trigger_error()
textpattern/publish/taghandlers.php:4116 assert_file()
textpattern/publish.php:1169 file_download()
textpattern/publish.php:1091 processTags()
textpattern/publish/taghandlers.php:3841 parse()
textpattern/publish.php:1169 if_custom_field()
textpattern/publish.php:1104 processTags()
textpattern/lib/txplib_misc.php:1681 parse()
textpattern/publish.php:838 parse_form()
textpattern/publish.php:955 doArticles()

Edit: There’s the error message.

Last edited by maruchan (2011-03-19 18:36:40)

Offline

#4 2011-03-19 19:04:27

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: File tags cannot be used outside of a file context?

Hmm… try this:

<txp:if_custom_field name="acclaim-comma-separated-file-id">
  <txp:file_download form="acclaim-files-short" id='<txp:custom_field name="acclaim-comma-separated-file-id" />' />
</txp:if_custom_field>

“acclaim-files-short” form:

<a href="<txp:file_download_link />" title="<txp:file_download_name /> -- <txp:file_download_modified format="%c" />">Acclaim (most recent, pdf)</a><br />

And if you want to avoid using a form here, you could probably do this instead:

<txp:if_custom_field name="acclaim-comma-separated-file-id">
  <txp:file_download_list id='<txp:custom_field name="acclaim-comma-separated-file-id" />'>
    <a href="<txp:file_download_link />" title="<txp:file_download_name /> -- <txp:file_download_modified format="%c" />">Acclaim (most recent, pdf)</a><br />
  </txp:file_download_list>
</txp:if_custom_field>

edit: fixed file_download_list tag should not be self-closing when used as a container tag.

Last edited by ruud (2011-03-19 22:40:32)

Offline

#5 2011-03-19 21:31:59

maruchan
Member
From: Ukiah, California
Registered: 2010-06-12
Posts: 596
Website

Re: File tags cannot be used outside of a file context?

Right on, that works. Thanks Ruud!

Offline

#6 2011-03-19 22:33:56

maruchan
Member
From: Ukiah, California
Registered: 2010-06-12
Posts: 596
Website

Re: File tags cannot be used outside of a file context?

OK, I thought it was working OK, but it wasn’t. I forgot I had the site in Live mode again. :-/

This file_download thing works — but how can I make it:

— sort by “modified desc” (or is that default?)
— show 3 files instead of 1.

code:

<txp:if_custom_field name="acclaim-comma-separated-file-id">
  <txp:file_download form="acclaim-files-short" id='<txp:custom_field name="acclaim-comma-separated-file-id" />' />
</txp:if_custom_field>

and…acclaim-files-short form:

<a href="<txp:file_download_link />" title="<txp:file_download_name /> -- <txp:file_download_modified format="%c" />">Acclaim (most recent, pdf)</a><br />

Thanks.

(Ruud: is file_download_list broken?)

Last edited by maruchan (2011-03-19 22:34:23)

Offline

#7 2011-03-19 22:47:08

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: File tags cannot be used outside of a file context?

Ah, well if the ‘id’ can contain multiple file ids then you’ll want to use file_download_list which does support a limit and sort attribute (unlike ‘file_download’).
Let’s continue in the topic you started about the file_download_list tag

Offline

#8 2011-03-19 22:47:21

maruchan
Member
From: Ukiah, California
Registered: 2010-06-12
Posts: 596
Website

Re: File tags cannot be used outside of a file context?

Nevermind…all fixed now

Offline

Board footer

Powered by FluxBB