Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-06-26 23:15:31

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

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

#2 2012-06-26 23:17:07

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

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?


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#3 2012-06-26 23:21:25

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

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

#5 2012-06-26 23:43:10

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

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

#6 2012-06-27 00:59:29

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

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

#7 2012-06-27 08:17:08

etc
Developer
Registered: 2010-11-11
Posts: 5,397
Website GitHub

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

Board footer

Powered by FluxBB