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..

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 18 2025 21:03:39
Script start
Timing: Jan 18 2025 21:03:39
Module start 'layout'
Timing: Jan 18 2025 21:03:39
Module start 'content'
Timing: Jan 18 2025 21:03:40
Module end 'content'
Timing: Jan 18 2025 21:03:40
Script end

Main resources:

Total runtime0.7936 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0053 588.0469152.6406
Module start 'layout' 0.00530.0030 740.687539.4766
Module start 'content' 0.00830.7838 780.1641543.9063
Module end 'content' 0.79210.0015 1,324.070312.4375
Script end 0.7935  1,336.5078 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.4206160.0002
Check MTime0.00130.1686160.0001
Mysql Total
Database connection0.00080.104210.0008
Mysqli_queries0.738993.1038570.0130
Looping result0.00060.0721550.0000
Template Total0.761295.920.3806
Template load0.00210.264920.0011
Template processing0.759195.656820.3796
Template load and register function0.00020.021710.0002
states
state_id_array0.00090.113310.0009
state_identifier_array0.00150.191120.0008
Override
Cache load0.00180.2211340.0001
Sytem overhead
Fetch class attribute can translate value0.00060.069920.0003
Fetch class attribute name0.00150.190040.0004
XML
Image XML parsing0.00210.263020.0010
class_abstraction
Instantiating content class attribute0.00000.001340.0000
General
dbfile0.00210.2654160.0001
String conversion0.00000.000840.0000
Note: percentages do not add up to 100% because some accumulators overlap

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/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 17
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs