Making external links property default to open new window

Author Message

Mark Emms

Tuesday 12 June 2007 3:54:47 am

I wish to change the default property for an external link entered in the XML editor to be a new window openeing rather than the current default value.

Many thanks in advance

André R.

Tuesday 12 June 2007 5:57:24 am

If you want to force it, you can override the templates/content/datatype/view/ezxmltags/link.tpl to set target to _blank on external domains.

If you don't want to force it, you can override templates/ezdhtml/insertlink.tpl and insertlink_geco.tpl to do some javascript stuff when the URL (linkUrl) looses focus.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Mark Emms

Tuesday 12 June 2007 6:13:50 am

Do you mean I should edit:

{section show=$target} target="{$target}"{/section}

and change it to

{section show=$target} target="_blank"{/section}

?

Many thanks Andre

André R.

Tuesday 12 June 2007 6:39:57 am

No, this will force new window on all links.
You have to compare the uri ( $href ) first to identify if this is an external link or not.

EDIT: to clerify, something like:

{if $target} target="{$target}{elseif and( $href|contains('http://'), not( $href|contains('http://www.yourdomain.com') ) )} target="_blank"{/if}

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

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 22:24:59
Script start
Timing: Jan 18 2025 22:24:59
Module start 'layout'
Timing: Jan 18 2025 22:24:59
Module start 'content'
Timing: Jan 18 2025 22:25:00
Module end 'content'
Timing: Jan 18 2025 22:25:00
Script end

Main resources:

Total runtime0.9428 sec
Peak memory usage4,096.0000 KB
Database Queries60

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 589.2891152.6563
Module start 'layout' 0.00630.0048 741.945339.5078
Module start 'content' 0.01100.9304 781.4531558.1094
Module end 'content' 0.94150.0013 1,339.562512.0938
Script end 0.9428  1,351.6563 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.3429160.0002
Check MTime0.00140.1467160.0001
Mysql Total
Database connection0.00070.079210.0007
Mysqli_queries0.885793.9414600.0148
Looping result0.00070.0732580.0000
Template Total0.904095.920.4520
Template load0.00160.173220.0008
Template processing0.902495.706820.4512
Template load and register function0.00010.009410.0001
states
state_id_array0.00110.120210.0011
state_identifier_array0.00150.161720.0008
Override
Cache load0.00150.1583220.0001
Sytem overhead
Fetch class attribute can translate value0.00070.075820.0004
Fetch class attribute name0.00220.231460.0004
XML
Image XML parsing0.00140.148920.0007
class_abstraction
Instantiating content class attribute0.00000.002180.0000
General
dbfile0.00180.1871230.0001
String conversion0.00000.001240.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
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.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: 19
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs