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.

eZ debug

Timing: Jan 31 2025 00:26:25
Script start
Timing: Jan 31 2025 00:26:25
Module start 'layout'
Timing: Jan 31 2025 00:26:25
Module start 'content'
Timing: Jan 31 2025 00:26:25
Module end 'content'
Timing: Jan 31 2025 00:26:25
Script end

Main resources:

Total runtime0.0246 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0057 588.1328151.2109
Module start 'layout' 0.00570.0042 739.3438220.6719
Module start 'content' 0.00990.0131 960.01561,001.8828
Module end 'content' 0.02300.0015 1,961.898437.9922
Script end 0.0245  1,999.8906 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002510.2858140.0002
Check MTime0.00103.9936140.0001
Mysql Total
Database connection0.00104.246910.0010
Mysqli_queries0.00249.678130.0008
Looping result0.00000.056310.0000
Template Total0.00114.710.0011
Template load0.00093.477110.0009
Template processing0.00031.144510.0003
Override
Cache load0.00052.219110.0005
General
dbfile0.00124.693480.0001
String conversion0.00000.028240.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.0001 secs