How to link to a file

There are several simple ways to link to a file you’ve uploaded in Textpattern.

TXP tags

You can use the <txp:file_download /> tag to generate a link to a file in Textpattern. This tag will output the file link according to the default files form, unless you specify another form. I like to set it up so that the file’s description becomes the linked text. You can use the file’s name or its id to specify the file:

<txp:file_download filename="sample-file.pdf" />

<txp:file_download id="2" />

To specify text of your choosing, you can use the <txp:file_download_link> tag. Again, either the file name or ID will work:

<txp:file_download_link id="2">Linked text here
</txp:file_download_link>

<txp:file_download_link id="sample-file.pdf">Linked text here
</txp:file_download_link>

Manual links

You can also create a link to a file using Textile markup, the same way you create a link to anything on the web:

"some text here":/blog/files/sample-file.pdf

"some text here updates":/blog/file_download/2/sample-file.pdf

Be aware that the first url is actually the path to where your files are stored. However, to keep the “Download count” correct, you should use the second path, in the form /file_download/ID/file-name.

Screencast

Check out the file linking options in this screencast:


No comments yet…Be the first!

Comments are closed for this article.