The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

attach link automatic to some words in the posts

View previous topic View next topic Go down

Solved attach link automatic to some words in the posts

Post by PE!N on November 21st 2011, 9:37 am

Hi
How are u all??

i've seen in many forums that the forum link automatic attach to some words in the posts .. example:

before: I walk through the valley of the shadow of death
after: I walk through the valley of the shadow of death

so is there any code or trick to do that or similar to it??


Last edited by PE!N on November 21st 2011, 7:54 pm; edited 1 time in total

PE!N
Forumember

Posts : 81
Reputation : 1
Language : english - arabic

http://www.ibri.hooxs.com

Back to top Go down

Solved Re: attach link automatic to some words in the posts

Post by ankillien on November 21st 2011, 10:26 am

Hi,

Here is a JavaScript...

Code:
$(function(){

$('.post .postbody').each(function(){

  var str = $(this).html();
  var newStr = str.replace(/TEXT_TO_REPLACE/gi, "REPLACE WITH THIS");
  $(this).html(newStr);

});

});

Add it to your forum via javascript code management for all pages.

Edit this line as per your requirement...

Code:
  var newStr = str.replace(/TEXT_TO_REPLACE/gi, "REPLACE WITH THIS");

Hope it helps Smile

ankillien
Energetic

Posts : 5198
Reputation : 129
Language : English, XHTML, CSS, JS, PHP, SQL

http://www.webartzforum.com/

Back to top Go down

Solved Re: attach link automatic to some words in the posts

Post by PE!N on November 21st 2011, 10:45 am

it's not working with me.

PE!N
Forumember

Posts : 81
Reputation : 1
Language : english - arabic

http://www.ibri.hooxs.com

Back to top Go down

Solved Re: attach link automatic to some words in the posts

Post by ankillien on November 21st 2011, 10:51 am

Where did you add the script?
Also post the full code that you added.

ankillien
Energetic

Posts : 5198
Reputation : 129
Language : English, XHTML, CSS, JS, PHP, SQL

http://www.webartzforum.com/

Back to top Go down

Solved Re: attach link automatic to some words in the posts

Post by PE!N on November 21st 2011, 2:30 pm

Code:
$(function(){
       
        $('.post .postbody').each(function(){
       
          var str = $(this).html();
          var newStr = str.replace(/TEXT_TO_REPLACE/gi, "REPLACE WITH THIS");
          $(this).html(newStr);
       
        });
       
        });

that is the code and it is added in javascript code management for all pages

PE!N
Forumember

Posts : 81
Reputation : 1
Language : english - arabic

http://www.ibri.hooxs.com

Back to top Go down

Solved Re: attach link automatic to some words in the posts

Post by ankillien on November 21st 2011, 3:14 pm

In above post, I had asked you to edit this line in the code...

Code:
var newStr = str.replace(/TEXT_TO_REPLACE/gi, "REPLACE_WITH_THIS");

For example...

Code:
var newStr = str.replace(/forum/gi, "<a href='http://forumotion.com/'>Forumotion</a>");

ankillien
Energetic

Posts : 5198
Reputation : 129
Language : English, XHTML, CSS, JS, PHP, SQL

http://www.webartzforum.com/

Back to top Go down

Solved Re: attach link automatic to some words in the posts

Post by PE!N on November 21st 2011, 7:53 pm

thanx sir .. it worked now when i deleted other java codes.

PE!N
Forumember

Posts : 81
Reputation : 1
Language : english - arabic

http://www.ibri.hooxs.com

Back to top Go down

Solved Re: attach link automatic to some words in the posts

Post by Sanket on November 21st 2011, 7:54 pm

Since this thread appears to be solved, I will archive this thread.


Sanket Smile


Sanket
ForumGuru

Male Posts : 48766
Reputation : 2819
Language : English
Location : Mumbai

http://webartzforum.com

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum