| |
|
| :: |
| Author |
Message |
daddyo
Joined: 12 Sep 2007 Posts: 47
|
Posted: Fri Sep 14, 2007 8:39 pm Post subject: Hot Linking |
|
|
Is there a Mod for Hot Linking -- making certain links linkable inside a post body?
Suppose someone is talking about Amazon, for example. I would want to have my system hot link Amazon so it appears as this:
Amazon
I tried doing this with the Word Censor, but if I create an entry with that such as
amazon -> amazon.com
Then, when someone posts "amazon.com", the word censor kicks in, replacing the "amazon", and I end up with
amazon.com.com |
|
|
| Back to top |
|
 |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 14814
|
|
| Back to top |
|
 |
daddyo
Joined: 12 Sep 2007 Posts: 47
|
Posted: Sun Sep 16, 2007 4:19 pm Post subject: Re: Hot Linking |
|
|
I don't have HTML enabled, so mine will have to be with BBCODE.
Amazon -> [url =http://www.amazon.com]amazon[/url]
Is there any way to have it search for lowercase/uppercase and replace, instead of making an entry for every possible version of "AmAzOn"??? |
|
|
| Back to top |
|
 |
SeO Administrateur - Site Admin

Joined: 15 Mar 2006 Posts: 3482
|
|
| Back to top |
|
 |
daddyo
Joined: 12 Sep 2007 Posts: 47
|
Posted: Sun Sep 16, 2007 5:21 pm Post subject: Re: Hot Linking |
|
|
Interesting. I never knew you could replace a word with HTML and have it display when HTML was turned off.
OK, so back to my question...
Can I have it search for all versions of a word (upper and lower) and wrap them with HTML tagging?
That'd be an edit in the code, right?
** I have discovered an issue **
Doing this replacement:
| Quote: | | amazon -> <a href="http://www.amazon.com">amazon</a> |
Replaces the word in my thread titles in viewforum.php and renders the link into the thread unclickable. Instead, it links the word "Amazon" to www.amazon.com and makes the rest of the title unlinked, so the only way to click into the thread is by clicking the "Last Post" graphic at the end of the line (which is very unclear to users). |
|
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 14814
|
Posted: Tue Sep 18, 2007 10:58 am Post subject: Re: Hot Linking |
|
|
Well yes, the censoring system is not really meant to do this.
You could hard code some custom replacement arrays, the code dealing with censoring in viewtopic.php is the following:
| Code: | if (count($orig_word))
{
$post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
if ($user_sig != '')
{
$user_sig = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $user_sig . '<'), 1, -1));
}
$message = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $message . '<'), 1, -1));
} |
So you could add something like :
| Code: | if (count($link_word))
{
$message = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$link_word, \$replacement_link, '\\0')", '>' . $message . '<'), 1, -1));
} |
Where $link_word would be the array of the word to be replaced by links, and $replacement_link the array of the corresponding links.
This way, you would only be filtering the message body, and not the titles on anything else unattended.
++ |
_________________ Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________
Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche |
|
| Back to top |
|
 |
daddyo
Joined: 12 Sep 2007 Posts: 47
|
Posted: Tue Sep 18, 2007 12:53 pm Post subject: Re: Hot Linking |
|
|
Thanks...
Unfortunately, I can't seem to get it to work...
I posted a message with 4 different versions of the word amazon...
AMazOn
amazon
amazon.com
www.amazon.com
And put the following code in:
| Quote: | $link_word=array("amazon");
$replacement_link=array("www.amazon.com");
if (count($link_word))
{
$message = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$link_word, \$replacement_link, '\\0')", '>' . $message . '<'), 1, -1));
} |
But it doesn't seem to do anything.
I tried putting the code segment in different places but it still seems to glance over it and ignore it. |
|
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 14814
|
Posted: Thu Sep 20, 2007 8:02 am Post subject: Re: Hot Linking |
|
|
All right, the full story is you need to prepare the word list a bit.
So the handiest would be to add the list in at the beginning of viewtopic.php if you only want to parse custom replacement in topics.
So try adding :
| Code: | // www.phpBB-SEO.com SEO TOOLKIT BEGIN
$link_word=array('amazon', 'myotherword');
$replacement_link=array('<a href="http://www.amazon.com">amazon</a>', '<a href="http://www.example.com">myotherword</a>');
foreach ($link_word as $key => $value) {
$link_word[$key] = '#\b(' . str_replace('\*', '\w*?', preg_quote($value, '#')) . ')\b#i';
}
// www.phpBB-SEO.com SEO TOOLKIT END |
Before :
| Code: | //
// Okay, let's do the loop, yeah come on baby let's do the loop
// and it goes like this ...
//
for($i = 0; $i < $total_posts; $i++) |
You of course can add other words there, and their replacement, but you need to use full html links for them to work.
And then :
| Code: | // www.phpBB-SEO.com SEO TOOLKIT BEGIN
if (count($link_word)) {
$message = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$link_word, \$replacement_link, '\\0')", '>' . $message . '<'), 1, -1));
}
// www.phpBB-SEO.com SEO TOOLKIT END |
after :
| Code: | if (count($orig_word))
{
$post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
if ($user_sig != '')
{
$user_sig = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $user_sig . '<'), 1, -1));
}
$message = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $message . '<'), 1, -1));
} |
It is not case sensitive, so AmaZon will be replaced the same as amazon in this example.
++ |
_________________ Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________
Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche |
|
| Back to top |
|
 |
daddyo
Joined: 12 Sep 2007 Posts: 47
|
Posted: Fri Sep 21, 2007 3:53 pm Post subject: Re: Hot Linking |
|
|
Awesome!
I wish I knew the phpBB code a bit more to be able to do this myself.
The only issue so far I could find with this hack, though, is that
if someone posts -www.amazon.com, the www.amazon part gets a link to www.amazon.com, but the remaining .com doesn't, so the link looks weird (like below)
www.amazon.com
This is what the HTML source looks like:
<a href="http://www.mysite.com/redirect.php?url=http://www." target="_blank">www.</a><a href="http://www.amazon.com">amazon</a>.com
I guess I need to add some kind of ignore functionality, since the regular linking will likely link it if it's in the form of -www.SOMEWEBSITE.com, right? |
|
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 14814
|
|
| Back to top |
|
 |
|
|
| Navigation |
Similar Topics |
|
|
|
|
|
|
|