Forums / Setup & design / Create a direct link to a binary file

Create a direct link to a binary file

Author Message

Nicolas Heiringhoff

Wednesday 28 July 2004 3:17:39 am

Hello erveryone,

we have some problems with creating a direct link to a binary file.
The PDF-files we want to offer for download a stored in a certain folder with the node id 296.
From an override-template of another folder in the tree-hierarchy we can grab the content of node 296 with the following code


{* Fetch everything that is under node #296 (children, grand-children, etc.) *}
{let nodes=fetch( 'content', 'tree', hash( 'parent_node_id', 296 ) ) }

{* Loop through the nodes and display their names. *}
{section loop=$nodes}

<br />
    <a href={concat("/content/view/full/",$:item.node_id)|ezurl}>{$:item.data_map.titel.data_text}</a>
    
    <br />
    {$:item.data_map.beschreibung.data_text}
    
    <br />
    
    {$:item.data_map.binaer.data_???}
    
    <br /> 

We can display the attributes title (identifier="titel") and description (identifier="beschreibung") but we can not display the actual file directly (identifier="binaer"), because we do not know the data_map. For the title and the description it is "data_text". We also used data_int before, to display numbers. Which data_map can we use to display the file?

When you click on the link that we generated with the code above, the file plus the filsize is displayed directly by the ezbinaryfile.tpl, that is used there. We want exactly that, but copying the ezbinaryfile.tpl in our override template does not work.

http://www.heiringhoff.de

Roy Bøhmer

Monday 02 August 2004 11:11:53 am

Sorry for the late answer. Hope you already have figured something out.
I've used this code whith success. Hope it helps.

<a href={concat("content/download/",
			$object.id,
			"/",
			$object.data_map.file.id,
			"/file/",
			$object.data_map.file.content.original_filename)|ezurl}>
			{$object.name|wash}</a>

You should replace <i>$object</i> with <i>$:item.object</i> and ensure that the attributename for the binary file in the class is file. If not, replace <i>file</i> with the attributename.

Roy

Nicolas Heiringhoff

Tuesday 03 August 2004 4:00:30 am

Hello Roy,

your code works perfectly fine!

Thank you very much!

Nicolas

http://www.heiringhoff.de

willy jansen

Monday 15 November 2004 9:39:12 am

Congratulations! Would you mind explaining how you solved this and what code you used. For at least one person (me) is looking for a similar solution, but the information above is not sufficient for me.

Nicolas Heiringhoff

Tuesday 16 November 2004 12:17:02 am

Hello Willy,

We put the files (pdfs in our case) in one folder (node id 296).
With the following code we can display the pdfs with a direct download link in a template.


{* Fetch everything that is under node #296 (children, grand-children, etc.) *}
{let nodes=fetch( 'content', 'tree', hash( 'parent_node_id', 296 ) ) }

{* Loop through the nodes and display their names. *}
{section loop=$nodes}


<br />

<span class="fett">{$:item.data_map.titel.data_text}</span>

<br />

{$:item.data_map.beschreibung.data_text}

<br />

<img src={"pdf_mini_icon.png"|ezimage}&nbsp; &nbsp; 

<a href={concat("content/download/",
                        $:item.object.id,
                        "/",
                        $:item.object.data_map.file.id,
                        "/file/",
                        $:item.object.data_map.file.content.original_filename)|ezurl}>
                        {$:item.object.name|wash}</a>

    <br />   
{/section}



{/let}

Regards,
Nico

http://www.heiringhoff.de

eZ debug

Timing: Jan 18 2025 15:55:47
Script start
Timing: Jan 18 2025 15:55:47
Module start 'content'
Timing: Jan 18 2025 15:55:49
Module end 'content'
Timing: Jan 18 2025 15:55:49
Script end

Main resources:

Total runtime1.1895 sec
Peak memory usage4,096.0000 KB
Database Queries202

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0065 587.8281180.8281
Module start 'content' 0.00651.0198 768.6563602.1250
Module end 'content' 1.02630.1632 1,370.7813337.3828
Script end 1.1895  1,708.1641 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00450.3809210.0002
Check MTime0.00150.1239210.0001
Mysql Total
Database connection0.00080.067810.0008
Mysqli_queries1.102992.71872020.0055
Looping result0.00220.18142000.0000
Template Total1.156197.220.5781
Template load0.00180.154520.0009
Template processing1.154297.033020.5771
Template load and register function0.00030.022610.0003
states
state_id_array0.00100.082410.0010
state_identifier_array0.00220.182220.0011
Override
Cache load0.00160.1331330.0000
Sytem overhead
Fetch class attribute can translate value0.00210.174840.0005
Fetch class attribute name0.00240.201560.0004
XML
Image XML parsing0.00280.239540.0007
class_abstraction
Instantiating content class attribute0.00000.001380.0000
General
dbfile0.00740.6186270.0003
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
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
10content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 27
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs