Friday, 4 December 2009
From my latest Google Analytics figures, 52% of the visitors to this website are from outside the UK. I decided to put Google Adsense on my blog posts as I wanted to show relevant ads and take advantage of it's geo-targeting features, so, for example, a visitor from Germany would see German adverts. I decided the best place for the ads is in the 'related posts' box below each blog article. As related posts are rendered from code behind by a custom control, it's not as simple as just pasting in the Google Adsense code. So, here's the trick to add Adsense, or anything else you want, to the related posts control.
Thursday, 8 October 2009
So, you've got two great things, the IntenseDebate commenting software and the BlogEngine.NET blogging software, and you want to combine them to make something greater than the sum of its parts. Here's how it's done.
- Pop over to IntenseDebate and get the JavaScript code they provide.
- Open up the file 'post.aspx', which is in the root folder of your blog.
- Disable the built in commenting system by setting the 'CommentView' usercontrol to 'visible = false' like so;
<uc:CommentView ID="CommentView1" runat="server" Visible="false" />
- Paste the IntenseDebate code below the disabled usercontrol, wrapping it in an 'If' statement so the code is only rendered if comments are enabled for the post;
<% if (Post.IsCommentsEnabled)
{ %>
<script language="javascript" type="text/javascript">
var idcomments_acct = 'YOUR ACCOUNT';
var idcomments_post_id;
var idcomments_post_url;
</script>
<script type='text/javascript' src='http://www.intensedebate.com/js/genericCommentWrapperV2.js'></script>
<% } %>
Voila! An ASP.NET powered blog with a web 2.0 commenting system.