PDA

View Full Version : A small Mod - Open links in new window option


MrRundog
03-28-2005, 08:40 AM
Hi, This is a small mod that will give visitors the option to stay connected to your site when using the links pages - You will need a small gif image of new window icon - saved into the linksDirectory/images folder - Call the image "window" This is how it goes -

Find in lib\smarty\plugins\modifier.linkalize
Find line-
function smarty_modifier_linkalize($url, $text, $target = '_top')
Replace with
function smarty_modifier_linkalize($url, $text,$target = '_top', $targetnew = '_new', $title = 'Opens in a new window' )
Find line-
return linkalize($url, $text, $target);
Replace with
return linkalize($url, $text, $target,$targetnew, $title);
Find line-
function linkalize($url, $text, $target) {
Replace with
function linkalize($url, $text, $target,$targetnew, $title) {
Find line-
$url = preg_replace("/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i", "<a target=\"$target\" href=\"$1\" class=link>" . (is_null($text) ? '$1' : $text) . "</a>$url);
Replace with
$url = preg_replace("/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i", "<a target=\"$target\" href=\"$1\" class=link>" . (is_null($text) ? '$1' : $text) . "</a> <a target=\"$targetnew\" href=\"$1\" class=link title=\"$title\"><img src=\"images/window.gif\" border=0></a>", $url);

Save & Upload.

Go to mysite [COLOR=darkred]to see what I mean & (grab the window icon)

Sometime in the future...HTML 4.0 Strict and XHTML 1.0 Strict recommendations of the W3C no longer include the target attribute of the <a> tag - To find out more go here... http://www.sitepoint.com/article/standards-compliant-world
I will rewrite all the above mod (for compliency) when i get a chance, but for now it's fine.

minstrel
07-14-2005, 06:09 AM
Content visible to registered users only.
I don't see any file by that name in RC4.

David
07-14-2005, 06:15 AM
Yes, this one was posted for phpld v1. Let me see if I can find the place you need to add target="_blank" in v2.

brb....

David
07-14-2005, 06:17 AM
Here we go...
{older non working link removed}

We should definitely make this configurable through admin.

minstrel
07-19-2005, 08:19 PM
Thanks, David (and thanks to Igonza for the code!).

I would definitely like to see this as either the default or an option in directory settings for RC5.

Ap0s7le
08-22-2005, 01:01 AM
Hey minstrel, this is now in RC5.2

later

-Casey

PS
Yell at me on IM sometime.

kickass
08-22-2005, 02:45 AM
target=_blank still validates for xhtml 1.0 transitional. There's also a dom thing you can do with javascript and that validates to strict, I'll see if I can find the link . . .

kickass
08-22-2005, 02:56 AM
Found it!
http://www.serve.com/apg/workshop/replacingTarget/

Think this can be morphed into the script somehow in a standards oriented way? As an external js that's called from every links page? There's gotta be a way, I have faith in you guys.

Ap0s7le
08-22-2005, 03:01 AM
Please tell me before I mod somethingggggggg :)

I'll look into it tomorrow.

later

-Casey

vkaryl
08-22-2005, 03:44 AM
BJ, from the link you posted I wasn't able to tell on a really quick look if it's this?

onclick="window.open(this.href);return false;" which gets inserted where you'd ordinarily have the target element....

I second your plea. This little bit of js is really pretty useful, and 99% of the browser-using world won't have a problem at all with it.... and an external js file is perfect.

Ap0s7le
08-22-2005, 05:40 AM
Nah, it's not that Vicki.

It actually uses an external JS to look for a specific class name to open in a new window. Kinda neat, should be easy to do.

later

-Casey

Ap0s7le
08-22-2005, 06:58 AM
Alrighty, implemented the JS solution.

Who can I get to test it for me?

Ladies? ;)

-Casey

kickass
08-23-2005, 02:49 PM
pm me with the details - and be specific about what I put where and how, k? I hate to play guessing games . . .

vkaryl
08-23-2005, 08:05 PM
Yep - ditto bj's post above, though I'm less picky about playing guessing games.... I probably have more time to do so than she, though!