Forums / Setup & design / link directly to a file

link directly to a file

Author Message

Michael Kress

Monday 24 March 2008 12:17:47 am

Hello, I'm using 3.9.2 but the effect also shows in 4.0 ...
I'd like to link directly to a pdf file that I've put as a child object under a pulicly accessible folder/article named /downloads. There I have many pdf files. It works by inserting an object that displays a little icon which I don't really like. So when I want to link there just with a text link, I can't link directly to the file, there is always a sort of wrapper link in front:
http://www.my.site/content/view/line/510
There, I get then the link to the actual file:
http://www.my site/content/download/640/3346/file/myfile.pdf

But I'd like to link directly to the latter, i.e. directly to the pdf file.
The only way to achieve this is to copy the link from the wrapper page and insert a text link that links there directly and not selected vie the object/node browser.

I hope, I expressed myself comprehensible. If you like to, I can post some screenshots somewhere documenting the actions I did...
TIA
Michael

Daniele Nocentini

Wednesday 26 March 2008 4:56:09 am

Hi!

try to insert this link in your full view template of your class with a ezbinaryfile datatype called "file":

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

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

Felix Laate

Wednesday 26 March 2008 5:39:19 am

Hi,

or maybe in embed/file.tpl? That's the code that gets embedded when you insert an object in a xml-field.

Felix

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

Daniele Nocentini

Wednesday 26 March 2008 6:36:11 am

it's the same thing, the embed view is tipically used for show a preview of object instead view embed-inline is used for show only a link to the object but you can choice the view do you prefer and replace code template with only a link for download or with others datatype.

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

John Kazakis

Thursday 27 March 2008 5:46:46 am

I'm using a similar code to the one posted above, but for some reason it doesn't work with spaces.

I have this code

    {if $node.object.data_map.file_version.has_content}
    	<span class="links"><a href={include uri= 'design:d_templates/file_url.tpl' attribute=$node.object.data_map.file_version}>VIP Access</a></span>
    {/if}

File_url.tpl:

{* This template print the url of a file attribute *}
{* Parameters:
        $attribute
*}

{concat("content/download/",$attribute.contentobject_id,"/",$attribute.id,"/file/",$attribute.content.original_filename)|ezurl}

When there's a file with spaces it shows "http://www.mywebsite.com/content/download/92121/511539/file/file%20name.pdf"

It doesn't change the spaces, and because of that I get a 404 module not found page. Is there any way for me to fix this?

I posted a thread about this, but unfortunately nobody seems to know what the issue is...

Felix Laate

Thursday 27 March 2008 6:37:20 am

@John

Are you using Firefox? Or dows this happen in every browser?

Felix

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

John Kazakis

Thursday 27 March 2008 8:11:03 am

Hello Felix,

Sorry I forgot to mention that it only happens in Firefox...

I'm using version 2.0.0.13

Stéphane Bullier

Thursday 27 March 2008 12:18:19 pm

Hello,

You can see this article : http://pwet.fr/blog/creating_a_link_to_download_a_file_with_online_editor_in_ez_publish

and this post : http://ez.no/developer/forum/developer/url_encode

Stéphane

Michael Kress

Thursday 27 March 2008 1:04:02 pm

Stéphane, Thanks for the blog link, I followed the steps there but I still got the wrapper page around, i.e. in front, I still have to click another link to get to the file.
Any ideas?
Cheers
Michael

Russell Michell

Wednesday 20 August 2008 9:10:26 pm

Michael, about 5 months too late I know but I had the same issue for images.

My solution (well-easy) would be as good as the same as for your situation.

See: http://ez.no/developer/forum/setup_design/solved_llink_a_thumbnail_image_to_larger_version#msg172802

Good luck :-)
Russ

Russell Michell, Wellington, New Zealand.
We're building! http://www.theruss.com/blog/
I'm on Twitter: http://twitter.com/therussdotcom

Believe nothing, consider everything.