Forums / Setup & design / object relation to download pdf document

object relation to download pdf document

Author Message

Tech Services

Thursday 17 May 2007 11:52:36 am

Hi,

I’m trying to create a “pdf version” link next to the “E-mail This Article”, “Print This Article” on the top of our article page. To create these links, the code is placed in our override article template as below:

<ul class="HorizList" id="page_tools">
<li><a href={concat('/content/tipafriend/',$node.node_id)|ezroot()}><img src="/images/icon.alert.envelope.gif" alt="Envelope" width="23" height="15" border="0" class="Icon">E-Mail This Article</a></li>
<li><a href="#" onclick="if (window.print) window.print(); return false;"><img src="/images/icon.print.gif" alt="Print Article" width="23" height="18" border="0" class="Icon">Print This Article</a></li>
</ul>

The actual pdf document for the “pdf version” link will be stored in the Media library/pdfs folder. Within pdfs folder, I will upload the pdf document in a file type class.

In order to relate the pdf document to the article, I have added an attribute, “object relation”, to an article class. I am using this attribute to link to a pdf document in the Media library.

To output the link, I wrote the code below:

{if $node.object.data_map.pdf_version.has_content}
<li><a href={$node.object.data_map.pdf_version.content.main_node.url_alias|ezroot()}><img src="/images/icon.adobe_pdf_logo.gif" alt="Download PDF Version" width="16" height="16" border="0" class="Icon">PDF Version</a></li>
{/if}

The link code, {$node.object.data_map.pdf_version.content.main_node.url_alias|ezroot()}, only takes me to the page where the pdf document is located:

http://www.something.com/media/pdfs/pdf_test

I’d like to create a link to download the actual pdf document as below:

http://www.something.com/content/download/343454/3434399/file/pdf_test.pdf

Is there a way to code the link to download the pdf document directly instead of going through an extra page?

I know that ezpublish has its own pdf creator, but our client wants to use their own pdfs..

I’m using version 3.8.7.

Please help.. Many thanks…

Niko Goers

Thursday 17 May 2007 12:49:59 pm

Hi,

try this:

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

The created link looks like: http://example.com/content/download/158/681/file/mypdfdocname.pdf

It should work. You just have to convert the link for your own requirements.

cheers

eZ Publish partner - http://www.all2e.com
http://share.ez.no/directory/companies/all2e-gmbh
http://ez.no/Partners/all2e-GmbH

Lords of Heaven - http://www.LoH-Gilde.de (Created with eZ Publish)
German online gaming guild

About me - http://www.NikoGoers.de

My roadmap, +1 are welcome: http://share.ez.no/community/roadmap/10889

Tech Services

Friday 18 May 2007 10:10:56 am

Thank you! You solved my problem..

eZ debug

Timing: Jan 18 2025 18:25:57
Script start
Timing: Jan 18 2025 18:25:57
Module start 'content'
Timing: Jan 18 2025 18:25:57
Module end 'content'
Timing: Jan 18 2025 18:25:57
Script end

Main resources:

Total runtime0.1530 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0080 588.9766180.8125
Module start 'content' 0.00800.0050 769.789198.0547
Module end 'content' 0.01300.1399 867.8438529.3750
Script end 0.1529  1,397.2188 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00352.2608200.0002
Check MTime0.00140.9449200.0001
Mysql Total
Database connection0.00100.656910.0010
Mysqli_queries0.108170.68631410.0008
Looping result0.00120.79111390.0000
Template Total0.139591.210.1395
Template load0.00100.653610.0010
Template processing0.138590.502210.1385
Override
Cache load0.00060.383710.0006
Sytem overhead
Fetch class attribute can translate value0.00100.649110.0010
XML
Image XML parsing0.00020.126710.0002
General
dbfile0.00251.6029200.0001
String conversion0.00000.004130.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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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