External links to open in new window

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
dk

External links to open in new window

Post by dk »

I'd like to open up all links inside entries or comments to a new window (target="_blank" or something like that)

Where do have to make the code changes?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: External links to open in new window

Post by garvinhicking »

Inside entries, you need to specify it in your text you write.

For comments, you need to edit 'comments.tpl' in the templates/default folder for Serendipity 0.8. In Serendipity 0.7, changing this is not recommended.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
dk

Re: External links to open in new window

Post by dk »

garvinhicking wrote:Inside entries, you need to specify it in your text you write.
If I click the "Link" button inside the entry editor it generates the html code automatically. Instead adding the target="_blank" command manually I prefer the idea that some code change could do this by default.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: External links to open in new window

Post by garvinhicking »

Ah, okay - I see. I think that code is created in serendipity_editor.js

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
SurfDude
Regular
Posts: 12
Joined: Sat Jan 01, 2005 8:30 pm
Location: Enschede, The Netherlands
Contact:

Re: External links to open in new window

Post by SurfDude »

garvinhicking wrote:Ah, okay - I see. I think that code is created in serendipity_editor.js

Regards,
Garvin
I wanted the same thing. You should indeed edit serendipity_editor.js (in the root of your serendipity) and edit line 69. Change this to

lft = "<a href="" + my_link + "" target="_blank">";
tom

Post by tom »

cool.. exacly what I was looking for!!
thanx
Chris
Regular
Posts: 49
Joined: Thu Dec 09, 2004 1:02 am
Location: Sydney, Australia
Contact:

Post by Chris »

This is what I've been looking for as well - works perfectly ! :)
ykoehler
Regular
Posts: 11
Joined: Sun Jan 30, 2005 12:57 am
Location: Montreal
Contact:

modifying anchor attributes...

Post by ykoehler »

Hi,

While reading this, it looked like that would be a nice hook to add to the plugin system. Maybe it already exists, but basically like they do for changing acronyms into links, they should also have post-processing event on link creation that would allow such manipulation.

An example could also be to remove specific tag or add a class statement to each <p> elements... etc. Just ideas.
Yannick Koehler
ykoehler
Regular
Posts: 11
Joined: Sun Jan 30, 2005 12:57 am
Location: Montreal
Contact:

hyperlink event plugins

Post by ykoehler »

Hi,

I just realized that by having such an event pluggable for hyperlink one could then implement in the same way as the "target='_blank'" the google 'nofollow' attribute.

An interface for the event would include information such as the link is pointing inside the site or externally, where that link came form, article, comment or layout. And a table containing the already specified attributes such as target, nofollow, class and others.
Yannick Koehler
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: hyperlink event plugins

Post by garvinhicking »

Hi Yannick!

Well, we do already have a plugin called "Fix common XHTML errors" which does tricks like that, to rewrite HTML tags.

And, of course, you could even use the content rewrite plugin to change '<p>' into '<p class="mine">'...

However I think you're more requesting an interface for this, right? How would you think that could look like? Last week I just created a "dynamiclinks" plugin which uses tags like {dynamic_link:img:X} to insert an image Number #X from the media libary. The good thing to use this dynamic variable is that if you rename the image in the media library, it will always show the latest path. But I don't really know how to build an interface for what you need. Could you create some fake screenshots or whatever, on how you imagine it to be?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
ykoehler
Regular
Posts: 11
Joined: Sun Jan 30, 2005 12:57 am
Location: Montreal
Contact:

Re: hyperlink event plugins

Post by ykoehler »

Hi Garvin,
garvinhicking wrote: However I think you're more requesting an interface for this, right? How would you think that could look like?
I am not sure if I was requesting something new. As I said, I don't know if something already exists that could do as dk requested. I was just pointing out that instead of fixing serenditpity_*.php files as SurfDude proposed, some kind of post-processing plugin system should be used or implemented so that whenever people want to do stuff like that they don't need to change the core php files.

If the Fix common XHTML errors plugin does that then maybe it should be named in a more generalized way or available under a new name as well as dk is definitely not fixing a tag to be XHTML compliant.

If something new is needed then I may not be the proper person to define in details the proper API for it as I have yet to start playing with the plugin interfaces. Still the elements I pointed out should be accessible from that interface in my opinion.
Yannick Koehler
mama99de

V0.9

Post by mama99de »

How does this work in the newest version (0.9) ?

Regards

Marcus
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: V0.9

Post by garvinhicking »

mama99de, please describe what you mean/want exactly.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Guest

Re: V0.9

Post by Guest »

garvinhicking wrote:mama99de, please describe what you mean/want exactly.
I tried this :

...and edit line 69. Change this to
lft = "<a href="" + my_link + "" target="_blank">";
I think it´s line 80 in version 0.9 but it doesn´t work...

All links in a blog should open in a new browser window.

Regards

Marcus
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: V0.9

Post by garvinhicking »

Hm, I still don't know what you want to do. You want to make all images open in a new browser window?

Install the serendipity_event_imageselectorplug plugin, this offers you to tell what "target" should be used for images...?!

Or please describe more datiled what you want to do/have, we also have a german forum. :)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply