Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-04-15 18:45:02

manastojones
Member
Registered: 2009-04-13
Posts: 14

How do you link to files?

I am having some trouble linking to files by using an id number. I am messing around with installing an audio player and would like to be able to use a custom_field tag to link each article with an individual file. But apparently you can’t do this outside of a file download form.

Here’s the code I am trying to use:

<object type="application/x-shockwave-flash" data="http://manasto.info/files/player.swf" id='audioplayer<txp:article_id />' height="24" width="290">
<param name="movie" value="http://manasto.info/files/player.swf">
<param name="FlashVars" value='playerID=<txp:article_id />&amp;soundFile=<txp:file_download_link id='<txp:custom_field name="File ID" />' />'>

I realize that this is not going to work, but i put it up here so you might understand how I am trying to go about this. Essentially, I would like it to work the same as the Article Image field, where all I have to do is upload a file, grab the id of the file, and place it my File ID custom_field.

My problem is there appears to be no way to tell textpattern to get the location of the file and just the url (with out any HTML tags) where I want it.

I know, I know. I could just get the location of the file and paste the url in a custom_field and just call that wherever I want it, but I would really like to know if just calling it by id is possible.

Any suggestions.

Last edited by manastojones (2009-04-15 18:46:08)

Offline

#2 2009-04-15 18:55:15

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: How do you link to files?

If I understand correctly you just need the URL of the file? Does this work:

<txp:site_url />file_download/<txp:custom_field name="File ID" />

Offline

#3 2009-04-15 19:06:24

manastojones
Member
Registered: 2009-04-13
Posts: 14

Re: How do you link to files?

I think I understand how to get it to work using a long url, but what I was asking was whether or not I could get it to work somehow by just usinig the id number of the file in the same way that all you have to do for including an Article Image is use the id number of the image file.

A better example: What if I uploaded an mp3 and called it awesome.mp3 and it had an id number of 3. If I were going to do it your way, the way you suggest above (which would work and is probably far more simple than what I am trying to figure out), than I would put awesome.mp3 in my custom_field and everything would be fine.

I was just wondering if there was some way I could enter the id number, which, for awesome.mp3, might be 3, in my custom_field and have textpattern output the url of the file whose id is the one I just passed to it.

Does that make any sense?

It’s not that I don’t want to do it the way you have described (I probably will), but I was just wondering if there was a way to do it by just entering the file id number in the custom_field…. just to see if it were possible.

Last edited by manastojones (2009-04-15 19:10:36)

Offline

#4 2009-04-15 19:26:25

redbot
Plugin Author
Registered: 2006-02-14
Posts: 1,410

Re: How do you link to files?

Don’t know… maybe you should try upm_file?

Offline

#5 2009-04-15 19:33:04

manastojones
Member
Registered: 2009-04-13
Posts: 14

Re: How do you link to files?

I think I’ll just do it your way. Probably easier in the long run.

Thanks for taking a look at it, though.

Last edited by manastojones (2009-04-15 19:39:01)

Offline

#6 2009-04-15 20:21:41

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: How do you link to files?

manastojones wrote:

but I was just wondering if there was a way to do it by just entering the file id number in the custom_field…. just to see if it were possible.

I don’t get it… all you have to do is enter the file ID number in your custom field, and put <txp:site_url />file_download/<txp:custom_field name="File ID" /> in your code where the url to the file should be (in your article form); what is different from how you expected it to work?

Offline

#7 2009-04-15 20:41:21

manastojones
Member
Registered: 2009-04-13
Posts: 14

Re: How do you link to files?

My bad…..

I didn’t understand that’s how the file_download path worked. I just assumed (wrongly) I would have to enter the file name in the custom_field to get a url like http://domain.com/file_download/awesome.mp3. I didn’t know a url like http://domain.com/file_download/4 would work. I apologize for that.

Your way works just the way I wanted it to.

All hail Els.

Offline

#8 2009-04-15 20:47:30

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: How do you link to files?

manastojones wrote:

I didn’t know a url like http://domain.com/file_download/4 would work.

Ah, I should have explained that better. Glad it works!

Offline

#9 2009-04-15 22:35:17

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: How do you link to files?

You still might want to take a look at upm_file and upm_file_popper


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#10 2009-07-30 06:58:21

aeonflux
Plugin Author
Registered: 2006-01-22
Posts: 33
Website

Re: How do you link to files?

I would also suggest that you use a plugin to point directly to the file. And not to the http://domain.ext/download/id

When you use the textpattern download function to get a file Textpattern forces the receiver to download the file. Even if you have streaming headers put in your file, it will not stream
.
This cant be a problem for small files but if you have big audio or video files it can be annoying that you have to wait until the whole file is loaded into the player before it will be played.

Offline

Board footer

Powered by FluxBB