phpBB SEO
Boards
Directory  
SEO  
Downloads
  phpBB SEO : Search Engine Optimization, Directory, Forums  
Index
Forums
Annuaire
Référencement
Télécharger
 
  Search Rechercher
    Register
Username :  Password :  Log me on automatically each visit  
S'enregistrer  
 
   
Hot Linking

 
Post new topic   Reply to topic    phpBB SEO » SEO Forum  » phpBB Forum
::  
Author Message
daddyo



Joined: 12 Sep 2007
Posts: 47

Hot LinkingPosted: 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
Administrateur - Site Admin


Joined: 28 Apr 2006
Posts: 14814

Hot LinkingPosted: Sun Sep 16, 2007 12:18 pm    Post subject: Re: Hot Linking

It should work with the censor system.

Try :

amazon -> <a href="http://www.amazon.com">amazon</a>

But this will cause some problem when trying to edit the entry, you'll have to do it with phpmyadmin to make it simple.

++

_________________
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
Visit poster's website
daddyo



Joined: 12 Sep 2007
Posts: 47

Hot LinkingPosted: 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
Administrateur - Site Admin


Joined: 15 Mar 2006
Posts: 3482

Hot LinkingPosted: Sun Sep 16, 2007 4:20 pm    Post subject: Re: Hot Linking

html is not activated here either.

_________________
phpBB SEO || SEO Forum || Forum Référencement
GYM Sitemap & RSS for phpBB3 has been released ! || GYM Sitemap & RSS for phpBB3 est disponible !
Back to top
daddyo



Joined: 12 Sep 2007
Posts: 47

Hot LinkingPosted: 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
Administrateur - Site Admin


Joined: 28 Apr 2006
Posts: 14814

Hot LinkingPosted: 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
Visit poster's website
daddyo



Joined: 12 Sep 2007
Posts: 47

Hot LinkingPosted: 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
Administrateur - Site Admin


Joined: 28 Apr 2006
Posts: 14814

Hot LinkingPosted: 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
Visit poster's website
daddyo



Joined: 12 Sep 2007
Posts: 47

Hot LinkingPosted: 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. Sad

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
Administrateur - Site Admin


Joined: 28 Apr 2006
Posts: 14814

Hot LinkingPosted: Mon Sep 24, 2007 10:23 am    Post subject: Re: Hot Linking

You can try to put this code before :

Code:
   $message = make_clickable($message);


in viewtopic.php, just in case it's enough Wink

++

_________________
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
Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    phpBB SEO » SEO Forum  » phpBB Forum
Page 1 of 1

Navigation Similar Topics

Jump to: