Link to file download

Author Message

David Jones

Wednesday 27 September 2006 3:45:59 am

I wont to add a perminant link to one of my custom templates to a file for download.

I can't seem to access the path to the file.

THis is what I have tried.

{def $hermes=fetch(content, tree, hash( 'object_id', 248) ) }

But

{$hermes.data_map|attribute(show)} 

Does not produce anything.

Of course, as this is going to be a perminiant link I could hard code it.
What would the direct link to this file (object Id 248) be?

Many thanks

Claudia Kosny

Wednesday 27 September 2006 4:08:45 am

Hi David

fetching content tree returns an array of treenodes which are childnodes of the node you supply. As you provide a object id I think you should have even gotten some errors in the debug messages, so make sure you look there any time something does not work as expected.

If you truly want to fetch the url to an object (and not a node) you use

{def $object= fetch('content', 'object', hash('object_id', $object_id))}

The link to this object is not necessarily clearly defined as an object can have several nodes assigned to it. Most likely you want to link to the main node:

<a href = {$object.main_node.url_alias|ezurl()}>{$object.name}</a>

If you want to fetch a single node you use

{def $node = fetch('content', 'node', hash('node_id', $node_id))}

The link to this node is then:

<a href={$node.url_alias|ezurl()}>{$node.name}</a>

Greetings from Luxembourg

Claudia

David Jones

Wednesday 27 September 2006 4:30:21 am

Thanks Claudia,

I've manage to work out the direct link to the file and if I stick that in a browser it downloads it.

Great.

However, I have put this into a javascript function, as the function needs to access the file to do some text transformation and the script doesn't seem to be able to find the file.

The portion of JS which is looking for the file is below.

//Replacement for Main home page title (Black bit)
sIFR.replaceElement(named({sSelector:"#spare1 h1", sFlashSrc:"/omf/content/download/248/1164/file/hermes.swf", sColor:"#000000;", sLinkColor:"#000000;", sBgColor:"", sHoverColor:"#CCCCCC", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=left&offsetTop=0", sWmode:"transparent"}));

I guess this is a long shot, but any thoughts?

David Jones

Wednesday 27 September 2006 7:20:36 am

I seem to have fixed this one thanks.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.