Sunday, 3 October 2010

Autolink for Blogger

Do you know Simple Tags plugin in Wordpress ? it will search in your post any words like category name and make it a link to this category .For example ,in your post ,there is a category name "abc" ,Simple Tags will find in your post the word "abc" and make it a link to abc category .

A friend ask me for making something similar to Simple Tags in Blogger . So now I want to introduce Autolink script in Blogger for you .


You can see the demo of this script in SimplexBlognews demo here
you can see in each post ,the word "Morbi" and word "nec" are autolinked to SimplexDesign blog .

Do you interested ?
Here is steps :
1,Open your template in word editor .

2,Add this line before </head>
<script src="http://dinhquanghuy.110mb.com/autotag.js" type="text/javascript"></script>

3,Find this line <b:if cond='data:blog.pageType == &quot;item&quot;'>
and look down ,you will see this code :
<p>
                                             <data:post.body/>                                 
                                         </p>
replace it with
<p>
                                         <div expr:id='&quot;summary&quot; + data:post.id'>
                                             <data:post.body/>
                                         </div>       
                                         <script type='text/javascript'>
                                             highlightSearchTerms('nec',true,'http://simplexdesign.blogspot.com','summary<data:post.id/>');
                                             highlightSearchTerms('morbi',true,'http://simplexdesign.blogspot.com','summary<data:post.id/>');
                                         </script>                                         
                                     </p>

take a look at the texts in bold . In this text ,"nec" and "morbi" is the text that script will find to add link , "http://simplexdesign.blogspot.com" is the link .
You can add more anchor text and link with this structure  
highlightSearchTerms('text you want to add link',true,'link','summary<data:post.id/>');
The script will find "text you want to add link" in your post and place a link "link" on this text .

This script is not as good as SimpleTags because SimpleTags using PHP and server resource for finding text and make link .Using this script you have to add text and link manually . But I think it's more flexible for you ,because you can use this script for advertising like Textlinkads ,search the text and link to advertiser .
I hope this script helpful to you . Feel free to comment here

17 comments:

  1. Great bro.. Autolink for spesific keyword..

    ReplyDelete
  2. With the limited resources we have on blogger, this is a tremendous resource for us! Wow! I really appreciate your effort.

    ReplyDelete
  3. this is cool script to work with much appreciated

    ReplyDelete
  4. Hi Huy,
    It's relly kol. But I'm afraid about the time of loading.. does it make the blog more slowly?

    ReplyDelete
  5. how to change the adsene link?

    ReplyDelete
  6. @Tue Minh : you can consider this script an ad script such as TextLinkads or Google adsense . Site will load slower if you using a lot of ad script .

    ReplyDelete
  7. Blogger now have Popular Posts Gadget, but I can't make it show thumbnails. Any ideas ?

    ReplyDelete
  8. You are right, I often use Picasa but still not work.

    ReplyDelete
  9. Nice tips, you make blogger blog better with your tricks, hacks and templates

    ReplyDelete
  10. This is unbelievably perfect.

    ReplyDelete
  11. It has a very small shifting problem as here: http://muhtesip.blogspot.com/search/label/Y%C4%B1lmaz%20%C3%96zdil

    The keywords are "Yılmaz Özdil" and "sayın Özdil". It work fine at the beginning but later the link shifts to the following letters.

    Is there a way to correct it?

    ReplyDelete
  12. Nice Trick Thanks For Sharing :)

    ReplyDelete
  13. How to autolink automaticaly to search words in content and link that for example:

    http://livekerala.blogspot.com/

    Pls Help.........

    ReplyDelete
  14. Yeah, The scripts has worked on my blog, Thx

    Although, i must add link manually, but that's okay for me... :D

    ReplyDelete
  15. i have add in my template its work but just in home page..

    in main post this script not woring

    and i have add readmore script some of the same script, how do I add it?

    http://www.dlme.info/

    ReplyDelete
  16. @dlme.info : I guess scripts are conflict . Please do as tutorial ,step by steps and do backup before each step . This will help you track where error is .

    ReplyDelete