Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-11-02 13:17:07

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,271
Website GitHub

Combine an external file_download_list?

Possibly a bit of a hacky solution to this, but a music site I’m making has some files stored in the local TXP database and some (for bandwidth reasons) stored on 3rd party sites like fileden.

I’d like to generate a complete list of all files for a particular artist and apply the formatting as given in form="dl_items” (which I normally supply to file_download_list).

Obviously, file_download_list only grabs the ones it knows about in the database. So can anyone think of a neat way, any way, to either pass file_download_list the details of the additional external files, or get file_download_list to give up a programmatically usable array of items so the full list can be generated and passed thru the dl_items form?

[ btw, dl_items displays conventional things like the description, filesize, etc, and also a clickable picture (if it exists) from txp_image with the same name as the file + “.jpg” ]

I figure I could either:

  1. “inject” the external details into a file_download_list() call (somehow!)
  2. make fake stubs in the files tab that (somehow!) point to the external files; or fake files in the ‘files’ directory that resolve (somehow!) to a remote URL
  3. grab the (unformatted) output of file_download_list (somehow!), merge it with my own array of external files and throw the whole lot (somehow!) through the dl_items form
  4. any other ideas?

Sorting them to make the “most recent” appear on top of the list might be problematic, but I’ll worry about that if I can get the full list in the first place :-) I suppose I could go all the way back to safe_rows() to get the local data from txp_files that way, then merge the local and remote arrays, but I might be duplicating code. Thing is, I can’t make head nor tail of how file_download_list does its magic in the core.

Many thanks in advance for anyone with any wisdom on how I might achieve this kind of thing. I’ve probably overlooked something obvious, as usual!

Last edited by Bloke (2007-11-02 13:17:26)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#2 2007-11-06 00:00:07

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,271
Website GitHub

Re: Combine an external file_download_list?

… or maybe not. Perhaps I’m asking the impossible? Anyone? … Anyone? … Bueller? … Anyone?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2007-11-06 18:07:34

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,599
GitHub Twitter

Re: Combine an external file_download_list?

Hi Stef.

I think it’s possible. But it’s a question for Core Developers.

Just want to thanks you for your amazing and funny plugins : I use smd_fuzzy_find ; smd_pull_quote and smd_slimbox.

Cheers,

Last edited by Pat64 (2007-11-07 07:21:40)


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#4 2007-11-06 18:59:24

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Combine an external file_download_list?

The filename column in txp_file can contain 255 characters. You could create dummy files with names that consist of a base64-encoded URL with “.link” added at the end.
For example, the URL http://www.textpattern.com/ would become the filename aHR0cDovL3RleHRwYXR0ZXJuLmNvbS8=.link

With a bit of PHP magic in the file_download_list form, you can create different display behavior based on the extension of the file_download_name.

Offline

#5 2007-11-06 21:52:55

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,271
Website GitHub

Re: Combine an external file_download_list?

Thanks for the replies guys.

@Pat64:
Thanks for the vote of confidence for the plugins. Glad you like ‘em. Hopefully fuzzy_find will officially be out of beta in the next few weeks, since nobody has complained too loudly.

@ruud:
Genius! Once again, you pull it out of the bag. Tried it and it works a treat and I can maintain the file order/dates/file sizes within the TXP database. Just 10 lines of PHP to handle both native and remote files in the download form.

Apart from the superwide Name column (hmm, I wonder if chunk_split() might help) and the fact that the interface claims the file is Missing (obviously), it’s as native as I could have hoped. As long as I make any edits in MySQL directly and remember that if a file says missing it isn’t necessarily missing, it’s a winner :-)

Next stop is to write myself a form to paste file details into that then generates the encoded details and publishes them directly to txp_file. A sort of “remote file upload” facility.

This is my happy face :-D :-D :-D :-D :-D :-D :-D :-D

Many thanks, ruud. I owe you (yet another) one.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#6 2007-11-06 22:20:47

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Combine an external file_download_list?

If you’re editing directly in MySQL, you may even get away with storing the URLs unencoded. Makes it easier to manage when editing and shorter as well (I’d avoid chunk_split). You can then distinguish them from real files by checking if they contain a backslash or start with http:\\.

What I intended in my previous post was creating a dummy file (1 byte text file) with such an encoded name, because having http:\\ in a filename probably doesn’t work very well.

Offline

#7 2007-11-06 22:40:54

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,271
Website GitHub

Re: Combine an external file_download_list?

ruud wrote:

What I intended in my previous post was creating a dummy file (1 byte text file) with such an encoded name

Ah, gotcha. In fact that works even better because it gets round the “missing” file syndrome and keeps absolutely everything in TXP.

Then all I need is the convenience form I already wrote that converts a text box contents into base64, make a 1 byte file and then upload it as normal via the TXP interface. Even better! Thanks for pointing that out, and I’ll avoid chunk_split on your recommendation :-)

Cheers.

EDIT: Of course, the file size in the TXP interface reports only 1 byte. But TXP doesn’t seem to mind if I change it via MySQL.

Last edited by Bloke (2007-11-06 23:01:30)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#8 2007-11-12 22:37:05

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,271
Website GitHub

Re: Combine an external file_download_list?

And lo, a plugin was born :-)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB