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.

eZ debug

Timing: Jan 18 2025 01:06:52
Script start
Timing: Jan 18 2025 01:06:52
Module start 'layout'
Timing: Jan 18 2025 01:06:52
Module start 'content'
Timing: Jan 18 2025 01:06:53
Module end 'content'
Timing: Jan 18 2025 01:06:53
Script end

Main resources:

Total runtime0.6589 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.0062 588.1328152.6406
Module start 'layout' 0.00620.0029 740.773439.4766
Module start 'content' 0.00920.6483 780.2500539.1016
Module end 'content' 0.65750.0014 1,319.351612.1250
Script end 0.6589  1,331.4766 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.6111160.0003
Check MTime0.00210.3163160.0001
Mysql Total
Database connection0.00070.106410.0007
Mysqli_queries0.604391.7070570.0106
Looping result0.00070.0993550.0000
Template Total0.626495.120.3132
Template load0.00210.321920.0011
Template processing0.624394.743320.3121
Template load and register function0.00010.012410.0001
states
state_id_array0.00130.203610.0013
state_identifier_array0.00080.125420.0004
Override
Cache load0.00180.2662520.0000
Sytem overhead
Fetch class attribute can translate value0.00040.067420.0002
Fetch class attribute name0.00110.160640.0003
XML
Image XML parsing0.00060.085420.0003
class_abstraction
Instantiating content class attribute0.00000.001750.0000
General
dbfile0.00080.1225160.0001
String conversion0.00000.000940.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
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 12
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs