Linking to a File (for download)

Author Message

Tony Stark

Friday 18 January 2008 12:57:16 pm

Hi,

In some cases I want to create a link to a file directly, where, clicking on a link to it will download it from within the article (or summary) instead of going to a sub page/object where you can do it. Is there anyway I can create a link to a file which will mean it downloads when you click on the link rather having to drill down to the item?

i.e. article > link > file download instead of article > link > article > file download..

Hope this makes sense....

Rémi Poulet

Friday 18 January 2008 10:18:46 pm

Hi Tony

On the online editor, you can select the elements you want to define as a hyperlink and in the hyperlink interface specify directly the node or url you want to you use. If I do understand well your question, I'd manage it directly like an external url.

Does it solve your problem?

Rémi

Tony Stark

Saturday 19 January 2008 11:14:53 am

Hi Rémi,

What I mean is (and this is my problem) is that when I am editing content and I want to include a file so that you can download it direct from the link - eZ (my install anyway 3.10.x) will allow me to upload file and I can select that file post upload for the hyperlink *but* when you click on that link it will take you to another page listing the file with a hyperlink. I wans to remove that extra step and have it when you link an object/node to a file that it is downloadable from that link.

Again, I hope this makes sense.

Thanks

Rémi Poulet

Saturday 19 January 2008 9:32:46 pm

Hi Tony,

I've just tried it to check, if the url you type in link directly to the object (media or file) not to the node which is holding the object (you can type the absolute url also) with a target in new window, you get directly the file without going through a intermdiate page in which you have the link to the file.

it means that in tha case instead of i.e. :
article > link > article > file download
You'll have directly article>link>file download

But don't take the Id of the article, take the file Id and use the object target in new window (most of the time your object is linked to the article and you'll have the pass through the article since it isn't the id of the file itself).

Hope it'll solve your problem

Regards

Remi

Tony Stark

Sunday 20 January 2008 3:21:28 am

Hi Remi,

I suppose the only problem here is you will have to get the link to a file directly before uploading/including the file etc. I suppose it is no big deal but it is a long way around to something you woudl think should be a case of edit article > create hyperlink > select file. If I am misunderstanding you, let me know! but it seems that you need to know the URL to the file first..?

Thanks

Tony.

Michael Kress

Monday 24 March 2008 1:04:41 am

Tony, have you found a solution for this?
I also posted pretty much the same question before I saw your thread:
http://ez.no/developer/forum/setup_design/link_directly_to_a_file
I tried Rémi's suggestion, but I ended up in this wrapper page containing the final download link.
TIA
Michael

Daniele Nocentini

Wednesday 26 March 2008 4:25:39 am

Hi Tony Stark!

You have to do to embed your file inside xml block of your article as a object and select view "embed-inline" then you make a override rule in your override.ini file:

[your_override_name]
Source=content/view/embed-inline.tpl
MatchFile=embed/file_embed-inline.tpl
Subdir=templates
Match[class_identifier]=file

inside the template file_embed-inline.tpl put this link to the file:

<a href={concat( 'content/download/', $object.data_map.file.contentobject_id, '/', $object.data_map.file.id,'/version/', $object.data_map.file.version , '/file/', $object.data_map.file.content.original_filename|urlencode )|ezurl}>{$object.name|wash}</a>

Antica Bottega Digitale srl
http://www.abd.it

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 16:05:32
Script start
Timing: Jan 18 2025 16:05:32
Module start 'layout'
Timing: Jan 18 2025 16:05:32
Module start 'content'
Timing: Jan 18 2025 16:05:32
Module end 'content'
Timing: Jan 18 2025 16:05:32
Script end

Main resources:

Total runtime0.0145 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 589.3438152.6250
Module start 'layout' 0.00560.0029 741.968839.4609
Module start 'content' 0.00850.0039 781.429797.4609
Module end 'content' 0.01230.0021 878.890638.3047
Script end 0.0145  917.1953 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002718.3854140.0002
Check MTime0.00128.2323140.0001
Mysql Total
Database connection0.00064.303610.0006
Mysqli_queries0.002819.345830.0009
Looping result0.00000.138110.0000
Template Total0.001812.210.0018
Template load0.00096.346110.0009
Template processing0.00085.814910.0008
Override
Cache load0.00064.269110.0006
General
dbfile0.00042.877980.0001
String conversion0.00000.054340.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0002 secs