Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Check for filenames in an article_custom form...
Some of the articles in the site I’m working on have multiple files associated with them using the upm_file plugin. The file types vary (.pdf, .doc, .mov).
The test:
I want to use an article_custom form on one of my pages to display only articles that contain at least one file with a filename ending in .mov
I know how to use smd_if to get this to work in a file form when used to output a file list within an article
I am having a hard time figuring out how to check for this within an article_custom form… in order to control the output of articles (not files) …. not sure if I can use smd_if or smd_query to check filenames and sort this out? Also — I wonder if there is a way to check to see if .mov is in any way associated with an article? i.e. – if a file_download tag is included in the body of an article instead of in the upm_file custom field (and the filename associated with the file_download tag ends in .mov)
- thanks in advance to anyone who has ideas/advice!
p.s. – I am trying to avoid having to include a category or custom field that has to be manually selected when .mov files are included with an article — I would rather use an internal “behind the scenes” type of test if possible.
Offline
Re: Check for filenames in an article_custom form...
photonomad wrote:
I want to use an article_custom form on one of my pages to display only articles that contain at least one file with a filename ending in .mov
I think it would not be too difficult to update upm_file_article_custom
for this, adding a file_type
attribute. Perhaps Mary would do that for you.
Edit: wouldn’t be perfect, since file type is not stored per se, as it is with images; would have to match against the file name.
Also — I wonder if there is a way to check to see if .mov is in any way associated with an article? i.e. – if a file_download tag is included in the body of an article instead of in the upm_file custom field (and the filename associated with the file_download tag ends in .mov)
Sounds like regular expression search against the Body field across the entire textpattern table — not feasible.
Last edited by jsoo (2009-09-30 09:05:36)
Code is topiary
Offline
Re: Check for filenames in an article_custom form...
Thanks for the input jsoo. I just solved most of my problem using the awesome <txp:variable /> tag!! I’m very excited…. this is my first time to really utilize (and understand) <txp:variable /> on my own. : )
Here it is:
<txp:article_custom limit="999">
<txp:variable name="articlefiles" value='<txp:upm_article_file_list form="video_file_list" />' />
<txp:smd_if field="txpvar:articlefiles" operator="contains" value=".mov">
<h1><txp:title /> has a movie!</h1>
<txp:else />
<h4><txp:title /> does not have a movie.</h4>
</txp:smd_if>
</txp:article_custom>
EDIT: fyi – the video_file_list form consists of one file tag: <txp:file_download_name />
Last edited by photonomad (2009-09-30 14:23:12)
Offline
Re: Check for filenames in an article_custom form...
Clever solution!
Code is topiary
Offline