Related Post Widget - Powered by Google


Displaying a related posts is a smart way for keeping your site visitors around. and you may have seen other Related Posts Widgets out there.. but this one will be Easier and Smarter. For example: see this site related post. To get this widget to your blogs do follow the below instructions check features list:
  1. Easier : since All of the work is(has to be) done on the client side, You will not need to modify your template at all. widget will read post tags that blogger already display with each post.
  2. Smarter : Cause This widget will list the top related 5(or more) posts sorted by relevancy! Top relevant posts are the posts that have more tags in common with the current post.
  3. More Optimized: Will only use summary feeds instead of querying default feeds that return full contents!
  4. This widget also can work as a recent posts widget when there is no tags to aggregate.
  5. Can be also used to get related posts from another blogspot blog. And in that case you don't have to run it on a blogspot!
  6. A fixed list of tags can be used to aggregate.
  7. It can display loading text or icon until widget is loaded.
  8. Related posts list can be styled based on relevancy!
  9. You can specify either to load widget on document ready or on window load.
  10. Widget will be attached to container specified or it will be placed where you made the JavaScript call.
To see the widget in action, Scroll down to the end of this post. also hover on links to see relevancy tip. This is the complete options table Every variable is optional. exclude it to have default value.
OptionDescriptionDefault value
blogURLOther Blog URL or leave empty to aggregate yours''
maxTagsmax tags to look for on the page5
maxPostsPerTagmax posts to be aggregated per tag5
maxPostsSpecify a max. to remove extra posts that are least relevant or set to 0 to keep them.5
containerSelectorjQuery Selector to find a container to append widget at the end of it, Use 'div.post-body' to have widget appended at the end of your post body. or leave empty so widget is placed where you called it''
tagsdon't specify any and tags are read from page content. or specify a fixed list to aggregate like ['jQuery','JSON']. also setting it to empty array [] will make it work as recent widget all the time.null means not fixed
loadingTextText to be displayed until widget is loaded. for example 'loading..' '' means no loading text
loadingClassCSS class will be set on list until widget is loaded which you can use to style the list with an AJAX icon on the background[ajaxload.info]. for example 'related-posts-loading' '' means no CSS class
relatedTitleH2 Title to be used for related posts widget. To disable title output set this to empty.'Related Posts'
recentTitleH2 Title to be used for recent posts widget when there are no tags on the page. Set this to empty and widget is canceled.'Recent Posts'
postScoreClassA CSS class prefix to be used to style posts based on relevancy. If you set to 'related-link' and maxTags=5 then related links can have classes like ('related-link1' to 'related-link5')'' so feature is disabled
onLoadtrue would insert widget on window load and after all page content(like images) is loaded. or false and widget is loaded after document is ready(before images)false
relevantTipFor demo purpose you can show each post relevancy as a tool tip. set to '\d relevant tags!' and '\d' is replaced with number of tags in common.''
If you want to understand code behind this widget, check [Code behind : A Smarter Related Posts widget for Blogger]. Typical Usage #1 To display related links at the end of every post. copy this code into a new HTML/Javascript widget and place at the bottom of the post or at the footer in the page elements section. Widget uses jQuery v1.3.2, If you already included jQuery into your blog. no need to do it again. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script> <script src="http://blogger-related-posts.googlecode.com/files/related-posts-widget-1.0.js" type="text/javascript"></script> <script type="text/javascript"> relatedPostsWidget({ 'containerSelector':'div.post-body' ,'loadingText':'loading...' });</script> [containerSelector : 'div.post-body'] is the default container selector of your post body as output by blogger. which means find 'div' tag with class="post-body" if you unlikely modified it; find your new selector. * Note that: - you should host widget javascript file on your own, Google code has no problem hosting the project javascript files. - You may also try Fileden as it is only file hosting I know that would give you a direct-link (A Must for javascript to work) or you can just upload it to your Google pages(phasing out). But keep the jQuery URL as is, since Google hosts jQuery(and others) very very well. Typical Usage #2 To show related links at the side column. copy this code into a new HTML/Javascript widget and place at the side in the page elements section. Again, If you already included jQuery into your blog. no need to do it again. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script> <script src="http://blogger-related-posts.googlecode.com/files/related-posts-widget-1.0.js" type="text/javascript"></script> <script type="text/javascript"> relatedPostsWidget({ 'loadingText':'loading...' });</script> Style Widget with CSS You wouldn't need any CSS unless you need extra customization. Check Project page for more information.. to follow project changes or request features or submit bugs.

{ 0 comments ... read them below or add one }

Post a Comment