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.