ezxmltext override with changes

Author Message

Håkan Bergman

Monday 03 May 2010 5:37:53 am

Hello,

I got an article where user adds PDF-documents in the body text through links in the editor and are using the eznode://<nodeid> feature. The link however is not linking to the object in question but to another url where ezbinary.tpl is loaded with a proper download link.

I thought that I could easily change in link.tpl where I could just make a switch case to match type file and create a different a href to match content/download but I don't really understand how link.tpl is called, from where and where the data comes from.

Can anyone explain how I could do this in my link.tpl override for ezxmltext?

Best regards,

Håkan

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

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 31 2025 04:36:16
Script start
Timing: Jan 31 2025 04:36:16
Module start 'layout'
Timing: Jan 31 2025 04:36:16
Module start 'content'
Timing: Jan 31 2025 04:36:17
Module end 'content'
Timing: Jan 31 2025 04:36:17
Script end

Main resources:

Total runtime1.2811 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.0060 588.1328151.2109
Module start 'layout' 0.00600.0034 739.343836.6484
Module start 'content' 0.00951.2705 775.9922948.7266
Module end 'content' 1.28000.0011 1,724.718812.1641
Script end 1.2810  1,736.8828 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.2529160.0002
Check MTime0.00130.0976160.0001
Mysql Total
Database connection0.00090.073810.0009
Mysqli_queries1.217695.0431570.0214
Looping result0.00050.0427550.0000
Template Total1.228695.920.6143
Template load0.00240.190520.0012
Template processing1.226295.713620.6131
Template load and register function0.00130.097710.0013
states
state_id_array0.00180.139710.0018
state_identifier_array0.00180.143620.0009
Override
Cache load0.00190.1517530.0000
Sytem overhead
Fetch class attribute can translate value0.00060.046220.0003
Fetch class attribute name0.00180.142840.0005
XML
Image XML parsing0.00280.218320.0014
class_abstraction
Instantiating content class attribute0.00000.000740.0000
General
dbfile0.00390.3030180.0002
String conversion0.00000.000840.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
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/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: 17
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs