Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#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

#2 2009-11-27 11:31:06

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

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

#4 2009-11-27 11:47:22

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

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

#5 2009-11-27 11:52:41

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

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

#7 2009-11-27 16:47:10

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

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

#9 2009-11-27 19:17:26

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,000
Website GitHub

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

#10 2009-11-27 21:26:04

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: Associate file with an article

What the hell does smd_each do? :-D

Offline

#11 2009-11-28 02:57:59

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

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

#12 2009-11-28 13:50:20

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Associate file with an article

Or also:

<txp:file_download_list id='<txp:custom_field name="downloads' />' />


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB