Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Using a wildcard in file_download_list category name?
I have several file categories like:
fun-downloads-january
fun-downloads-february
fun-downloads-march
…and I’d like to simplify the process of displaying all fun-downloads-*
categories using <txp:file_download_list category="(whatever)" />
. Is there a particular wildcard character I should use? Thanks.
Last edited by maruchan (2012-06-26 23:15:49)
Offline
Re: Using a wildcard in file_download_list category name?
If a wildcard doesn’t exist then cound’t you make these into child categories and then display everything under the parent’s children?
Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker
Offline
Re: Using a wildcard in file_download_list category name?
Yes, but I had a different use in mind for parent categories, unfortunately.
Offline
#4 2012-06-26 23:42:26
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Using a wildcard in file_download_list category name?
smd_query maybe?
Offline
Re: Using a wildcard in file_download_list category name?
In case wildcards aren’t available, I’m leaning toward smd_query. I used it last night for another feature, and it was like the scene at the end of The Truman Show where he finds the door in the wall. :-)
Offline
Re: Using a wildcard in file_download_list category name?
OK, switched it to smd_query. Thanks Stef! :-) Here’s the code I’m using:
<txp:smd_query break="li" wraptag="ul" query="select * from txp_file where category like 'fun-downloads%' order by modified desc">
<a href="<txp:site_url />file_download/{id}/{filename}">{title}</a>
<txp:else />
<txp:variable name="no-results-message" />
</txp:smd_query>
I love that it lets you use <txp:else />
in there. Fantastic.
Edit: Now I’m wondering about displaying the category title. I guess I need to join the tables.
Last edited by maruchan (2012-06-27 01:00:19)
Offline
Re: Using a wildcard in file_download_list category name?
This is an alternative solution: select the categories, then pass the list to <txp:file_download_list />
.
<txp:variable name="fun-downloads">
<txp:smd_query break="," query="select name from txp_category where type='file' and name like 'fun-downloads%'">
{name}
</txp:smd_query>
</txp:variable>
<txp:file_download_list category='<txp:variable name="fun-downloads" />' />
This way you benefit from all the features of <txp:file_download_list />
.
Last edited by etc (2012-06-27 08:18:39)
Offline