TXP Plugins

arc_article_file :: Mar 2, 06:34 PM

A simple Textpattern plugin that produces a link to a file associated with an article, comparable with Textpattern’s <txp:article_image /> tag.

Installation

To install go to the ‘plugins’ tab under ‘admin’ and paste the plugin code into the ‘Install plugin’ box, ‘upload’ and then ‘install’. Finally activate the plugin. Please note that you will need to set-up a custom field to use for associating files with articles, unless you choose to embed the new tag in the article text; see the ‘Quick start’ guide below for further details.

Quick start

Use the following methods after the plug-in has been installed.

Method 1 – recommended
  1. Define a custom field, ‘Article file’, under preferences.
  2. Place the tag <txp:arc_article_file /> in a form where you want the download link to appear.
  3. Associate a file with an article by entering the Textpattern ID of the file, its filename, or its URL into the Article file field.
Method 2
  1. Enter <txp:arc_article_file file=”TXP file ID“ /> into an article where you want the link to appear setting the file attribute the Textpattern ID of the file associated with the article, its filename, or its URL.

Syntax

<txp:arc_article_file />

<txp:arc_article_file>Download file</txp:arc_article_file>

Attributes

Required

None.

Optional
Attribute Description Default Example
file Textpattern’s file ID or filename, or the URL of the file, use if you want to override the custom field unset file=“13”
link Set to ‘1’ to link to file, ‘0’ to output filename only 1 link=“0”
wraptag HTML tag to be used as the wraptag, without brackets unset wraptag=“p”
class CSS class attribute for wraptag arc_article_file class=“download”
custom Name of the custom field containing file IDs associated with article Article file custom=“file”

Plugin details

Initial release: 20 October 2008
Current version: 0.3 [ download ]

Please feel free to leave your comments and questions about this plugin below.

Use of my plugins is free; however, if you would like to show your appreciation you can do so by clicking the 'Donate' button below and make a contribution to the Andy Carter's coding fund via PayPal...

Comment

  1. Hi,

    Is there any way for this plugin to simply output the filename and without the < a href markup?

    Regards
    Martin

    Martin Walker · Feb 25, 12:22 AM · #

  2. Hi Martin, I’ve just tweaked the plugin to do what you want. Just feed it the attribute link=“0” to force it to output only the filename. Make sure you are using version 0.3 of the plugin to do this.

    Andy · Mar 2, 06:37 PM · #

  3. Champion!

    Martin Walker · Mar 2, 11:55 PM · #

E-mail address is optional and kept private. You will be asked to preview your comment before submitting it to the site to protect against spam.

Textile Help

Recent plugins

Textpattern links

Textpattern CMS

Textpattern forums
Textpattern's support forums.

Textpattern Resources
A directory of plugins, tutorials, and other resources for and by the Textpattern community.

TXP Tips
Tips, tutorials, and code to help build better Textpattern websites.

TXP's Textbook

We Love TXP
Design gallery of sites using Textpattern.

Recent blog posts