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.