ezxmltext override with changes

ezxmltext override with changes

Monday 03 May 2010 5:37:53 am - 2 replies

Author Message

Robin Muilwijk

Monday 03 May 2010 12:01:55 pm

Hi Håkan,

I might not have a solution for you but something similar crossed my path some time ago. This topic was related to getting a direct link to a file (download) to work. See http://share.ez.no/forums/setup-design/direct-link-to-a-file-on-image#comment56455, maybe the code and/or method used can help you.

Regards Robin

Board member, eZ Publish Community Project Board - Member of the share.ez.no team - Key values: Openness and Innovation.

LinkedIn: http://nl.linkedin.com/in/robinmuilwijk // Twitter: http://twitter.com/i_robin // Skype: robin.muilwijk

Håkan Bergman

Tuesday 04 May 2010 12:31:50 am

Hello Robin,

Thanks a lot for that link, I have now solved my problem!

The original code only printed the {$content} of every single URL but with that code I managed to tweak it.
This is content/datatype/ezxmltags/link.tpl file (overriden in my own extension)

{* Begin Code *}

---------------------------------------------------------------------------------------------------------------------------------------------------------

{* Define values we are checking for: type, content, attributes and URL *}

{def $protocols=array('http', 'file', 'ftp', 'mailto', 'https')
$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">{$attribute.object.name}</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}

---------------------------------------------------------------------------------------------------------------------------------------------------------
{* End Code *}

You must be logged in to post messages in this topic!

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