Forums / Setup & design / Direct link to file

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:)

eZ debug

Timing: Jan 18 2025 10:25:11
Script start
Timing: Jan 18 2025 10:25:11
Module start 'content'
Timing: Jan 18 2025 10:25:12
Module end 'content'
Timing: Jan 18 2025 10:25:12
Script end

Main resources:

Total runtime1.4478 sec
Peak memory usage4,096.0000 KB
Database Queries199

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0057 588.8203180.8438
Module start 'content' 0.00571.3225 769.6641607.1641
Module end 'content' 1.32820.1195 1,376.8281337.3984
Script end 1.4477  1,714.2266 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00410.2863210.0002
Check MTime0.00150.1041210.0001
Mysql Total
Database connection0.00090.064410.0009
Mysqli_queries1.372394.78911990.0069
Looping result0.00170.11851970.0000
Template Total1.413897.720.7069
Template load0.00220.149720.0011
Template processing1.411697.504920.7058
Template load and register function0.00020.014210.0002
states
state_id_array0.00110.075810.0011
state_identifier_array0.00130.087620.0006
Override
Cache load0.00180.1253420.0000
Sytem overhead
Fetch class attribute can translate value0.00110.074640.0003
Fetch class attribute name0.00100.069760.0002
XML
Image XML parsing0.00130.091740.0003
class_abstraction
Instantiating content class attribute0.00000.000960.0000
General
dbfile0.00410.2831350.0001
String conversion0.00000.000430.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 22
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs