Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2009-11-27 11:00:28
- leafy_loader
- Member
- Registered: 2008-09-25
- Posts: 96
Associate file with an article
How do I associate a downloadable file to an article.
There doesn’t seem to be an intuitive way of doing it. Is it similar to assigning an image, if so where’s the field to enter the file id on the write article page?
Offline
Re: Associate file with an article
You’ll need upm_file and upm_file_popper for this.
Offline
#3 2009-11-27 11:41:08
- leafy_loader
- Member
- Registered: 2008-09-25
- Posts: 96
Re: Associate file with an article
OK thanks, it’s a wonder why it wasn’t built in from the start.
Offline
Re: Associate file with an article
The core is by design and intention lean, but quite powerful. While there could be an argument for including this capacity in the core, it is also easy to extend the core’s capability by using a plugin.
Offline
Re: Associate file with an article
With the upm_ plugin, you can insert your file into an article’s “Files” field. This is a custom field, and you may need to rename the field in Preferences.
In order to display the files, here is some code to get you started:
<txp:article limit="1">
<h2><txp:title /></h2>
<txp:body />
<h2>File downloads:</h2>
<txp:upm_article_file_list form="files" />
</txp:article>
The “files” form is the default form for files. Just change that according to your needs.
Offline
#6 2009-11-27 13:06:37
- leafy_loader
- Member
- Registered: 2008-09-25
- Posts: 96
Re: Associate file with an article
Muchos grazias (sp)
Offline
Re: Associate file with an article
actually, all you really need is a custom field… call it article_file if you like. no plugin required.
Offline
#8 2009-11-27 17:31:28
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: Associate file with an article
mrdale wrote:
actually, all you really need is a custom field… call it article_file if you like. no plugin required.
I think this only works with a single file as the id attribute of the “<txp:file_download />” tag doesn’t accept multiple values (at least it isn’t documented).
In this case you have to use upm_file or the new rah_repeat
Offline
Re: Associate file with an article
In this case you have to use upm_file or the new rah_repeat
Or smd_each :-)
TXP Builders – finely-crafted code, design and txp
Offline
Offline
Re: Associate file with an article
redbot wrote:
In this case you have to use upm_file or the new rah_repeat
The markup for that might look something like:
<txp:rah_repeat value='<txp:custom_field name="downloads" />'>
<txp:file_download id='<txp:rah_repeat_value />' />
</txp:rah_repeat>
Offline
Re: Associate file with an article
Or also:
<txp:file_download_list id='<txp:custom_field name="downloads' />' />
Offline