a direct link to download a file from the online editor

Author Message

Veronique Jamilloux

Tuesday 25 May 2010 3:19:40 am

Hi,

I would like make a direct link on a downloaded file from online editor

From the online editor, in a xmltext attibute, I would like make a direct link on downloaded file which is in Media/file folder.

With the online, I select the word where I would like make the link and I use the link icone. In the edit <link> tag window, I write in the href propertie, /content/download/256 but it miss a attribute

256 is the object file id of my download file corresponding to $node.data_map.file.contentobject_id. But I need the $node.data_map.file.id. How can I have this last id? I look for it with admin interface but I don't find this information when I edit this object file.

Any idea about this?

Thanks a lot

Véronique

URGI - INRA
Webmaster
Route de Saint Cyr
78000 Versailles

Håkan Bergman

Tuesday 25 May 2010 5:10:49 am

I did this with another approach with an override of link.tpl for content datatype xmltags.

The template check if the link is a file and then prints a direct link to the object, if not, just prints the default link value.

/extension/myextension/design/myextension/templates/content/datatype/view/ezxmltags/link.tpl:

{* Define values we are checking for protocols, content, attributes and URL *}
{def $protocols=array('http', 'file', 'ftp', 'mailto', 'https', 'image')
$mycontent = ""
$attribute = ""
$url = false()
}
{* Fetch content from path *}
{set $mycontent=fetch(content, node, hash(node_path, $href))}
{* Verify the path URL and identify the source *}
{switch match=$href}
{* If the path is a file object, print the direct URL to file for download *}
{case match=$mycontent.object.class_identifier|eq('file'))}
{set $attribute=$mycontent.data_map.file}
{set $url=concat( '/content/download/', $attribute.contentobject_id, '/', $attribute.id,'/version/', $attribute.version , '/file/', $attribute.content.original_filename|urlencode )}
<a href={$url|ezurl} target="_blank">{$content}</a>
{/case}
{* If no match was made, print the default URL link *}
{case}
<a href={$href|ezurl}
{if $id} id="{$id}"{/if}
{if $title} title="{$title}"{/if}
{if $target} target="{$target}"{/if}
{if $classification} class="{$classification|wash}"{/if}
{if and(is_set( $hreflang ), $hreflang)} hreflang="{$hreflang|wash}"{/if}
>
{$content}
</a>
{/case}

{/switch}

Veronique Jamilloux

Tuesday 01 June 2010 1:41:09 am

Hi,

Ok I'm going to try your solution.

Thank you very much

Véronique

URGI - INRA
Webmaster
Route de Saint Cyr
78000 Versailles

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