Direct link to file

Author Message

Søren Knudsen

Tuesday 11 August 2009 8:48:27 am

Hi all,

I have been trying to implement what I thought should be an easy fix. What I want, is to let administration interface users create links to directly to pdf files contained in a folder in the media section by pointing at the object. This would enable visitors on the website to click a link on for example the front page and be linked directly to a pdf file.

The xml in the admin should look like:

<link href='ezobject://ID' target='_blank'>PDF</link>

and this generates the normal code html output:

<a href="/content/view/line/ID" target="_blank">PDF</a>

I would like to make it generate something like:

<a href="/content/download/.../.../file/..." target="_blank">PDF</a>

I have read these threads:

http://ez.no/developer/forum/general/link_to_pdf_file__1
http://ez.no/developer/forum/general/how_to_open_the_pdf_added_to_a_xml_bloc
http://ez.no/developer/forum/setup_design/files_with_spaces
http://ez.no/developer/forum/setup_design/link_directly_to_a_file
http://ez.no/developer/forum/setup_design/open_pdf_file_in_browser_window
http://ez.no/developer/forum/setup_design/open_pdf_directly_in_a_new_browser_window_from_link_in_oe/re_open_pdf_directly_in_a_new_browser_window_f__6
http://ez.no/developer/forum/setup_design/how_to_create_a_download_link_to_a_pdffile
http://ez.no/developer/forum/setup_design/directly_open_related_pdfdocuments_in_articles
http://ez.no/developer/forum/setup_design/create_a_direct_link_to_a_binary_file
http://ez.no/developer/forum/setup_design/datatype_binaryfile_display
http://ez.no/developer/forum/setup_design/creating_a_link_to_a_file_for_download
http://ez.no/developer/forum/setup_design/pdf_open_directly

but none of them describes a solution that I have been able to function. If one of these threads do describe such a solution, I might need to have a few more details to make it happen in my end.

/Søren

Łukasz Serwatka

Tuesday 11 August 2009 1:26:15 pm

Hi,

embed-inline tag can work for you. Users can navigate, pickup a file as related object and embed it in the XML block as embed-inline element. Then make a tpl file for the File class (I assume it is a File class) which in embed-inline view will show as <a href="content/download/....">{$object.name|wash()}</a> In addition you can also pass custom parameters if you require any.

http://ez.no/doc/ez_publish/technical_manual/4_0/reference/xml_tags#object_embedding

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Damien Pobel

Wednesday 12 August 2009 7:04:10 am

Hi Søren,

I wrote an article about this topic in my blog :
http://pwet.fr/blog/creating_a_link_to_download_a_file_with_online_editor_in_ez_publish

It's a bit old with a screenshot of Online Editor 4 (ezdhtml) but it should work with Online Editor 5 (ezoe) with a few changes.

Cheers.

Damien
Planet eZ Publish.fr : http://www.planet-ezpublish.fr
Certification : http://auth.ez.no/certification/verify/372448
Publications about eZ Publish : http://pwet.fr/tags/keywords/weblog/ez_publish

Søren Knudsen

Sunday 16 August 2009 11:58:21 pm

Thank you Łukasz. That did the trick. I had completely overlooked the posibility of inserting the object in for example an article, and not a link.

Damien: I forgot to mention that I had allready read your blog entry, but couldn't make it work. I succeeded adding the download class, but making the link_download.tpl template linking to the object's binary content was the problem.

Thank you both for helping out, anyway:)

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