Missing Target="_blank" for the Website Field

michael-zitrox
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 30 Mar 2010, 22:58

Missing Target="_blank" for the Website Field

Post by michael-zitrox »

Hi There,

I need quite fast a solution for the missing target="_blank" part in the entries for websites.
If someone fill in his website, it should open with "_blank" not self.

How should these lines look like?

Code: Select all

foreach ($this->items as $key => $values) {
	//Maximum of links in the message
	$rand 				= '%phoca' . mt_rand(0,1000) * time() . 'phoca%';
	$ahref_replace 		= "<a ".$rand."=";
	$ahref_search		= "/<a ".$rand."=/";
	$values->content	= preg_replace ("/<a href=/", $ahref_replace, $values->content, $this->tmpl['max_url']);
	$values->content	= preg_replace ("/<a href=.*?>(.*?)<\/a>/",	"$1", $values->content);
	$values->content	= preg_replace ($ahref_search, "<a href=", $values->content);
Current:
<a href="mysite.com">mysite.com</a>

Should be:
<a href="mysite.com" target="_blank">mysite.com</a>
michael-zitrox
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 30 Mar 2010, 22:58

Re: Missing Target="_blank" for the Website Field

Post by michael-zitrox »

no one?
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47810
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Missing Target="_blank" for the Website Field

Post by Jan »

It seems like you need some special regular expression, but it is no easy so this needs to be adviced by some regular expression expert :-(

Jan
If you find Phoca extensions useful, please support the project
michael-zitrox
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 30 Mar 2010, 22:58

Re: Missing Target="_blank" for the Website Field

Post by michael-zitrox »

this should be more than easy for the devs.. they used it anyway a few lines above.

by the way, i can't understand, why someone would create links without a target, i mean.
this is basic html.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47810
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Missing Target="_blank" for the Website Field

Post by Jan »

Hi,
by the way, i can't understand, why someone would create links without a target, i mean.
this is basic html.
the problem is, target is not basic html feature, e.g. in xhtml strict the target is not valid attribute. So if there is an open source project which can be used by different site, there should be added only basic features so they can be then customized.

second problem is, this is not feature of Phoca Guestbook, the links are set by the editor, so maybe this should be the question on editor developers :-( :-(

Jan
If you find Phoca extensions useful, please support the project
michael-zitrox
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 30 Mar 2010, 22:58

Re: Missing Target="_blank" for the Website Field

Post by michael-zitrox »

editor? no.
in the latest guestbook version, there is an "website" text-field.
so the url shouldn't be in an editor field.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47810
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Missing Target="_blank" for the Website Field

Post by Jan »

Aha, sorry I didn't understand it correctly, I thought, you are speaking about links in editor.

This you can customize in the code, see:
components\com_phocaguestbook\views\phocaguestbook\tmpl\default.php

cca line 160 - just add the target="_blank" there.

Jan
If you find Phoca extensions useful, please support the project
michael-zitrox
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 30 Mar 2010, 22:58

Re: Missing Target="_blank" for the Website Field

Post by michael-zitrox »

aaaaaaah "homesite" ;)
i searched all files for "website" ;)

Thanks a lot.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47810
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Missing Target="_blank" for the Website Field

Post by Jan »

Ok
If you find Phoca extensions useful, please support the project
Post Reply