Forums / General / Open the link in a new window

Open the link in a new window

Author Message

Kruglova Natasha

Thursday 28 January 2010 12:57:10 am

Help please.
I need that links to other domains opened in a new window.

I am in the template design/standard/templates/content/datatype/view/ezurl.tpl added target="_blank", but then all links open in a new window.

{section show=$attribute.data_text}
<a href="{$attribute.content}" target="_blank">{$attribute.data_text|wash( xhtml )}</a>
{section-else}
<a href="{$attribute.content}">{$attribute.content|wash( xhtml )}</a>
{/section}

Has found at a forum this code but as it to apply in a template ezurl.tpl I do not understand.

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

Kruglova Natasha

Thursday 28 January 2010 1:48:54 am

Please help me!

Question:

1. Please get me variable with my domain. Example midisa.net

2. How to do comparisons of variables? Coincidence and a finding contained in the text is necessary not precisely. For example I need to find, eat a name of my domain in a variable or not.

3. How correctly to write conditions? In one cases you write {if} {else} {/if} in other cases you use {if} {elseif} {endif}. You are not confused?

Please edit a code which it is resulted more low that it worked. This code is taken from a template ezurl.tpl

{if not( $attribute.content|contains('midisa.net')}
{$target = "_blank"}
{else}
{$target = "_self"}
{/if}

{section show=$attribute.data_text}
<a href="{$attribute.content}" target="{$target}">{$attribute.data_text|wash( xhtml )}</a>
{section-else}
<a href="{$attribute.content}" target="{$target}">{$attribute.content|wash( xhtml )}</a>
{/section}