Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2024-03-15 10:54:24
- Gallex
- Member
- Registered: 2006-10-08
- Posts: 1,308
file download link
txp 4.8.8
php 8.1.27
my code
<p><txp:file_download_link id='<txp:if_custom_field name="PDF"><txp:custom_field name="PDF" /></txp:if_custom_field>'>Laadi alla PDF</txp:file_download_link></p>
getting errors:
Tag error: <txp:if_custom_field name="PDF"><txp:custom_field name="PDF" /></txp:if_custom_field> -> Textpattern Notice: Field pdf not found. while parsing form numbrid on page default
textpattern/publish/taghandlers.php:4388 trigger_error()
if_custom_field()
textpattern/vendors/Textpattern/Tag/Registry.php:140 call_user_func()
textpattern/lib/txplib_publish.php:559 Textpattern\Tag\Registry->process()
textpattern/lib/txplib_publish.php:409 processTags()
textpattern/lib/txplib_misc.php:2216 parse()
textpattern/lib/txplib_publish.php:545 splat()
textpattern/lib/txplib_publish.php:409 processTags()
textpattern/lib/txplib_misc.php:3551 parse()
textpattern/lib/txplib_publish.php:1158 parse_form()
Tag error: <txp:file_download_link id='<txp:if_custom_field name="PDF"><txp:custom_field name="PDF" /></txp:if_custom_field>'>Laadi alla PDF</txp:file_download_link> -> Textpattern Notice: File tags cannot be used outside a file context. while parsing form numbrid on page default
textpattern/vendors/Textpattern/Tag/Registry.php:142 trigger_error()
textpattern/lib/txplib_publish.php:559 Textpattern\Tag\Registry->process()
textpattern/lib/txplib_publish.php:409 processTags()
textpattern/lib/txplib_misc.php:3551 parse()
textpattern/lib/txplib_publish.php:1158 parse_form()
textpattern/publish.php:1110 parseList()
textpattern/publish.php:1197 doArticles()
textpattern/publish.php:921 parseArticles()
article()
textpattern/vendors/Textpattern/Tag/Registry.php:140 call_user_func()
i have created that custom field name PDF and i have uploaded the pdf file :(
Moderator EDIT: changed bq.
to bc.
to prevent textile converting quotes.
Offline
#2 2024-03-15 18:17:10
- GugUser
- Member
- From: Quito (Ecuador)
- Registered: 2007-12-16
- Posts: 1,473
Re: file download link
Offline
Re: file download link
Buried in the error message is your clue:
Textpattern Notice: File tags cannot be used outside a file context
Untested, but try:
<txp:if_custom_field name="PDF">
<txp:file_download_list id ='<txp:custom_field name="PDF" />' wraptag="p">
<txp:file_download_link>Laadi alla PDF</txp:file_download_link>
</txp:file_download_list>
</txp:if_custom_field>
You probably want to do the if_custom_field test outside of the tag, because a) you get a blank <p></p>
and b) if there is no value given for the PDF, it will want to produce a link to nothing, e.g id=''
. Not specifying an id
is permitted, but then it expects you to be in a file context, like in the example above.
So … maybe your original variant will also work as long as you prevent the empty id from occurring, i.e. with the if_custom_field
placed outside the tag.
EDIT I: mea culpa, philippe is right, it should be file_download_list
. Corrected above.
EDIT II: I just tested it on the demo, the second option without file_download_list
also works, you just need to prevent the case of a non-existent custom field from coming up:
<txp:if_custom_field name="PDF">
<txp:file_download_link id ='<txp:custom_field name="PDF" />' wraptag="p">Laadi alla PDF</txp:file_download_link>
</txp:if_custom_field>
TXP Builders – finely-crafted code, design and txp
Offline
Re: file download link
Shouldn’t that be <txp:file_download_list > […] </txp:file_download_list>
instead of <txp:file_download />
(if using as a container tag)?
The latter is, according to the docs, a single tag.
That said, perhaps <txp:file_download form="form_name" id="xxx" />
could be an option, and form_name
contains:
<txp:file_download_link>Laadi alla PDF</txp:file_download_link>.
I use <txp:file_download_list> </txp:file_download_list>
in a similar context as @Gallex.
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
Offline
Re: file download link
Philippe, you’re right. I’ve corrected it above.
TXP Builders – finely-crafted code, design and txp
Offline
#6 2024-03-19 08:54:02
- Gallex
- Member
- Registered: 2006-10-08
- Posts: 1,308
Re: file download link
i choosed philip code. i only needed to change <txp:if_custom_field name="PDF">
to <txp:if_custom_field name="pdf">
cause it didn’t like a uppercase
thank you guys again!
Offline
Pages: 1