Forums / Setup & design / Linking to a File (for download)

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