Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-06-12 14:59:05

pmjewett
Member
Registered: 2008-06-12
Posts: 15

[textile] How can I change the "files" form to truncate the displayed filename?

I’m working on the new Human Resources page on our corp intranet and I’ve had dozens of files submitted by them to be displayed for download on their page. Some of the filenames are quite long (and include an .ext of course) and while I can’t change the name of the actual files I would like to know how I could have them auto-truncated.

HR staff will be uploading/deleting files on their own and I have the following tag on their page.

<p><txp:file_download_list category=“HR-Benefits” form=“files” limit=“10” sort=“filename asc” />

Anyone have any ideas?

Thanks very much from a newbie!

Offline

#2 2008-06-12 15:13:05

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

Re: [textile] How can I change the "files" form to truncate the displayed filename?

Does rvm_substr help? It chops text at a specified number of characters.

Or perhaps the original sab_substr (also available on ruud’s page).

Last edited by Bloke (2008-06-12 15:13:46)


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 2008-06-12 15:22:40

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,303

Re: [textile] How can I change the "files" form to truncate the displayed filename?

As file_download_list uses forms, you can as well put an smd_query of above bloke into that form, wich calls the desription from table txp_file you entered in the file’s description box.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#4 2008-06-12 15:32:19

pmjewett
Member
Registered: 2008-06-12
Posts: 15

Re: [textile] How can I change the "files" form to truncate the displayed filename?

I’ll try that but the caveat scares me……I don’t currently have a backup of this site…am I taking to big a chance trying it?

Thanks

Offline

#5 2008-06-12 16:05:59

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

Re: [textile] How can I change the "files" form to truncate the displayed filename?

pmjewett wrote:

I’ll try that but the caveat scares me……I don’t currently have a backup of this site…am I taking to big a chance trying it?

Smaller than eating a tomato. Basically only one line of code, in example with sab_substr plugin:

<txp:sab_substr limit="30"><txp:file_download_name /></txp:sab_substr>

That goes to your files form.

Last edited by Gocom (2008-06-12 16:07:16)

Offline

#6 2009-03-03 12:48:12

paulyoung
Member
Registered: 2008-06-21
Posts: 10

Re: [textile] How can I change the "files" form to truncate the displayed filename?

Is there any way to remove the file extension?

e.g. with Podcast.mp3 as the file name

<txp:sab_substr limit="-4"><txp:file_download_name /></txp:sab_substr>

Or even if someone could tell me how to access the download_file_name global variable so I can change it in PHP like so:

<txp:php> $name = $thisfile['filename']; substr_replace($name ,"",-4); echo $name; </txp:php>

Thanks

Offline

#7 2009-03-03 16:24:14

paulyoung
Member
Registered: 2008-06-21
Posts: 10

Re: [textile] How can I change the "files" form to truncate the displayed filename?

To answer my own question…
<txp:php> $name = file_download_name(); $name = substr_replace($name ,"",-4); echo $name; </txp:php>

Offline

Board footer

Powered by FluxBB