Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
<txp:file_download_list /> test for last file?
I’m trying to use a conditional (or maybe if_variable) to test for the last file in a list
page:
<txp:file_download_list wraptag="ul" class="download-list" break="" form="files" category="downloads" limit="100" sort="filename asc" />
form:
<li class="file"><txp:file_download_link><txp:file_download_name /></txp:file_download_link></li>
Currently all <li>‘s get the “file” class – I’m trying to leave that off the last file.
Any thoughts?
Thanks for the help – I’m a little thick today.
Offline
#2 2009-08-20 18:02:59
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: <txp:file_download_list /> test for last file?
On the page, you could set a variable’s value to the amount of your files.
<txp:variable name="file-countdown" value='<txp:jmd_count table="txp_file" />' />
And inside your form you could diminish the value for each pass by
<txp:adi_calc name="file-countdown" subtract="1" />
and react upon the amount by <txp:if_variable name="file-countdown" value="1">
Sorry for not serving copy-and-paste code, and without any links, I’m in a hurry now.
EDIT: Oh, you have to run another test, whether you have reached the 100-limit. But I think that’s as well doable with JM’s count tag.
Last edited by uli (2009-08-20 18:05:51)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: <txp:file_download_list /> test for last file?
Uli,
Excellent work – Thank You!
That’s exactly what I needed.
Cheers!
—
Tom
Offline
#4 2009-08-20 18:06:57
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: <txp:file_download_list /> test for last file?
Tom, I’ve edited while you were answering.
(Welcome.)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: <txp:file_download_list /> test for last file?
Sah-weet!
I’ll give it a whirl in an hour or so and report back – just to verify your genius!
:)
Edit: The 100 limit isn’t really needed in this case – but there are situations where I would need the limit.
Thanks for heads up on that.
Last edited by renobird (2009-08-20 18:13:59)
Offline
#6 2009-08-20 20:09:10
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: <txp:file_download_list /> test for last file?
renobird wrote:
The 100 limit isn’t really needed in this case
If it makes sense to limit the amount of files shown you could even have a plugin-less solution with two file_download_list tags employing offset and limit. D’oh.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline