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