This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Forums » Setup & design » open link in a new window? help needed
expandshrink

open link in a new window? help needed

open link in a new window? help needed

Monday 19 May 2003 5:07:06 pm - 7 replies

Hi!
I need some help with Link datatype (URL). I have a folder with a list of links (class id number 25) wich I want to be opened in new windows. When viewing them "line_class_25.tpl" is used, and the HTML link (< a href="... >text< /a>blunk.gif Emoticon is created with the code:

{ attribute_view_gui attribute=$content_version.data_map.link }

To open the link in a new window some HTML (target=_blank) or JavaScript code should be written inside the < a> tag but, as it is created dinamically with the template code I don't see the way to do it.
I also tried to access directly the attribute which has the URL in the Link object (and then write the HTML code directly in line_class_25.tpl) but didn't find the way to. I didn't know what was the object structure and the attribute names.

I hope I explained my problem clearly enough, thanks in advance for all the help provided.

Berto

Tuesday 20 May 2003 4:36:19 pm

the solution was to modify "/design/standard/templates/content/datatype/view/ezurl.tpl"

greetings from a newbie :P

berto

Friday 10 October 2003 12:31:34 pm

Sorry i kick this topic, but this is exactly the problem i'm having now!

I saw and tested your solution and it works, but this is not the perfect sollution.

The perfect sollution would be if you could choose per link if it needs to be opened in a new browser or not.

For example:
In the standard class "article" i added the datatype "url" (just to test). The best way should be if you've got here an option for it. Just an checkbox if it needs to open a new window.

Is this possible to do this? I must say i'm a newbie with ezPublish.

Friday 10 October 2003 3:15:22 pm

J W, here are some ideas that I have cobbled together from some of my templates. You may have to tweak them a bit to get it to work.

1. Add a checkbox to your class - For this example I am going to call it 'New Window?' and assign it the identifier 'newwindow'.

2. Add a section block that checks the checkbox to your code:
{section show=eq($content_version.data_map.newwindow.content,'')}
{* Displayed if the "New Window" box is not checked *}
{section-else}
{* Displayed if the "New Window" box is checked *}
{/section}

3. Within the second section in the above code insert your code to display a link that opens in a new window. Set the first section to display it normally.

4. Here is part of the code I use in an image override templateto open an image in a JavaScript window (the actual JavaScript is included in a different part of the window):
<a href={$image_content[original].full_path|ezroot} target="_soopaPop:width={$image_content[original].width},height={$image_content[original].height},screenX=50,screenY=50,resizable"><img src={$image.full_path|ezroot} width="{$image.width}" height="{$image.height}" {section show=$hspace}hspace="{$hspace}"{/section} {section show=$alignment}align="{$alignment}"{/section} border="{$border_size}" alt="{$image_content.alternative_text|wash(xhtml)}" /></a>
{/let}

Hope this helps. Let me know if something doesn't make sense.

Alex

Monday 13 October 2003 11:17:54 am

Alex, thanks for your answer.

It does make sense and your sollution works.

But it isn't exactly the thing i want. The best sollution is, in my opinion, that when you create an class, and you add an datatype "URL", that you can choose there the target of the link.

I think this is one thing that is not possible (yet). So i'm going to use your sollution.

Thanx.

Modified on Monday 13 October 2003 11:18:44 am by J W

Monday 13 October 2003 3:47:43 pm

Ahhh, I think I see what you would like. Perhaps for now you could add an extra text line to your link/URL class where you can fill in the target. Then edit the code in an override template for ezurl.tpl to include
target="{path.to.your.textline}"

Would this do what you want?

Alex

Monday 13 October 2003 4:29:04 pm

Yes, that will work, i think.

The only problem is that i don't know how to add the "link/URL class" so we can fill in the target.

I hope someone could explain that to me.
I'm really a newbie with ezPublish and i'm trying to understand how everything works, that's why i don't know how to do this on myself.

Monday 13 October 2003 4:49:18 pm

Do you mean you do not know how to edit the class or how to modify the code that the code outputs?

To edit the class go to your admin area and click on the 'Set up' tab and view the Classes. Click on the Edit link next to the Link datatype (mine is set up as number 11). Scroll down to the bottom of the box where it says Datatype and choose the 'Text line' from the drop down box and click on 'New'. The page will reload and provide you with some fields to fill out. For this example put 'Target' in the Name field and 'target' in the Identifier field. You could also do this with the Enum operator if you want to force the editor to select from a list.

Now when you add a link to eZ publish you will see the Target field, which you can fill in with the value you want for the target (_blank for example).

To output your code you will want to create an override for the ezurl.tpl file. Copy the file ezurl.tpl from design/standard/templates/content/datatype/view/

Place it in your override design directory and modify the code so it provide the target. An example might be:
{default node_name=$node.name}
<a href={concat('/',$node.url_alias)|ezroot} target="$node.data_map.target.content">{$node_name|wash}</a>
{/default}

Use something along these lines in your override.ini.append:

[url_with_target]
Source=node/view/line.tpl
MatchFile=url_with_target.tpl
Subdir=templates
Match[class]=25

Note: The above code may require some changes to work with your set up. I wrote this off the top of my head - I haven't tested it. It may have mistakes in it.

Does this help?

Alex

Modified on Monday 13 October 2003 4:50:54 pm by Alex Jones

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from