HashOut: Blogger Hacks
Showing posts with label Blogger Hacks. Show all posts

NoFollow No More

UPDATE: Since Google does not allow author link in Blogger comments anymore, HashOut does not support nofollow free author links anymore.

NoFollow No More - You Comment I Do FollowI felt that the people commenting on this blog were not really getting their due. The NoFollow attribute which comes by default with the Blogger templates just stifles the incentive to comment. I've thus decided to remove NoFollow from the comments section. And since my comments are moderated, I have no worries about spam as I can decide what goes live.

Hope that will entice you to comment more and actively participate in the discussions.

For those of you who are interested in removing the NoFollow attribute from the anchor tags in the comments section of your blog but do not know how, here is a simple guide to remove NoFollow from Blogger layouts (only for the new Blogger Layout templates). » Continue reading

Read more on , , ,

Placing AdSense Ads in the middle of Blogger posts

Hackman has an interesting hack to place AdSense ads right in the middle of your blogger posts. In this hack, Hackman places a HTML comment at the desired location in the post body while composing the post. Then using JavaScript he moves the contents before the HTML comment to a blank <div> tag before the AdSense code.

Hackman's hack is meant to work with the classic templates of Blogger. I have tweaked it a little to make it work for the new Blogger (layout) template. Here you go...

Find the <data:post.body/> tag in your new Blogger (layout) template and replace it with (Use copy-paste as some text below might be out of view):

<b:if cond='data:blog.pageType == "item"'>

<div expr:id='"adsensical" + data:post.id + "start"'></div>

<div style="margin:5px 0 -5px 10px">
<!--PLACE YOUR AD CODE HERE-->
</div>

&lt;div id="adsensical<data:post.id/>end">
&lt;div id="adsensical<data:post.id/>body">
</b:if>
<data:post.body/>
<b:if cond='data:blog.pageType == "item"'>
&lt;/div>
&lt;/div>

<script language="JavaScript">&lt;!--
//AdSensical Place Ads in Middle of Blogger Posts
//By hackman_3vilGuy http://adsensical-adsense.blogspot.com
//hackman {AT}caller {DOT}me {DOT}uk
//Modified for New Blogger (Layout) Template by Aziz (http://hashout.blogspot.com/)
topbit=document.getElementById("adsensical<data:post.id/>start");
bottombit=document.getElementById("adsensical<data:post.id/>end");
s=document.getElementById("adsensical<data:post.id/>body").innerHTML;
var regexIndex=s.search(/&lt;!--adsense-->/igm);
if(regexIndex>0) {topbit.innerHTML=s.substr(0,regexIndex);bottombit.innerHTML=s.substr(regexIndex+14);}
//-->
</script>
</b:if>


Now just replace <!--PLACE YOUR AD CODE HERE--> with your AdSense JavaScript code which you got from AdSense Setup and place <!--adsense--> anywhere within your post where you want the ad to appear (Make sure you insert it in Edit HTML mode).

The above code displays ads only on item (post) pages. If you want to display the ads on main or archive pages also, just remove the <b:if cond='data:blog.pageType == "item"'> and </b:if> tags. AdSense will automatically display only the first three ads on the page (in order of its appearance in the HTML) including the ones outside the posts section.

If you do not insert the HTML comment into your post content (HTML), then the ads will appear before the post body, but after the post title.

If you would like to see it working live before you begin implementing it on your blog, take a look here.

Related posts:
» Continue reading

Read more on , , ,

Excluding the first post from Expandable Post Summaries hack for Blogger

In continuation of my earlier post Excluding the first post from a Peek-a-boo style post body contents-hack for Blogger let me show you how to implement this same trick for the Expandable Post Summaries hack for Blogger.

Just like the Peek-a-boo exclusion trick we will use the getElementsByClassName function to fetch the full contents of the first post and make it visible. But before you proceed further you need to have the Expandable Post Summaries Hack already implemented on your blog.


Once you have done that:

  1. Copy and paste the getElementsByClassName JavaScript function between the <head></head> tags.
  2. Then search for the posts loop. It should look somewhat like this:
    <b:loop values='data:posts' var='post'>
    <b:if cond='data:post.dateHeader'>
    <h2 class='date-header'><data:post.dateHeader/></h2>
    </b:if>
    <b:include data='post' name='post'/>
    <b:if cond='data:blog.pageType == "item"'>
    <b:include data='post' name='comments'/>
    </b:if>
    </b:loop>

    Now add the following lines of JavaScript code immediately after that.
    <script type='text/Javascript'>
    &lt;!--
    getElementsByClassName("fullpost")[0].className = "";
    getElementsByClassName("contreadlink")[0].style.display = "none";
    -->
    </script>

  3. Finally add a class to the Continue Reading link so that we can hide the link for the first post.

    Search for this tag:
    <b:if cond='data:post.url'> » <a expr:href='data:post.url' title='Permanent Link'>Continue reading</a></b:if>

    and replace it with
    <b:if cond='data:post.url'><span class="contreadlink"> » <a expr:href='data:post.url' title='Permanent Link'>Continue reading</a></span></b:if>


Thats it, you're done!

If you have a better way to achieve the end result, do let us know.
» Continue reading

Read more on , ,

Excluding the first post from a Peek-a-boo style post body contents-hack for Blogger

I had earlier written a post on Peek-a-boo post body contents-hack for New Blogger in response to which many asked for a way to exclude the first post from the hack. That is displaying the full contents of the first post alone.

Here I will show you a hack to implement this using JavaScript. If you have not already implemented the hack as given in the previous post, do so first.

Then insert the following lines of JavaScript code anywhere between the <head></head> tags. Preferably add them after the expandcollapse function between the same script tags.
<script type='text/Javascript'>
&lt;!--
function getElementsByClassName(clsName) {
var retVal = new Array();
var elements = document.getElementsByTagName("*");
for(var i = 0;i &lt; elements.length;i++){
if(elements[i].className.indexOf(" ") >= 0){
var classes = elements[i].className.split(" ");
for(var j = 0;j &lt; classes.length;j++){
if(classes[j] == clsName)
retVal.push(elements[i]);
}
}
else if(elements[i].className == clsName)
retVal.push(elements[i]);
}
return retVal;
}
-->
</script>


Then search for the posts loop. It should look somewhat like this:

<b:loop values='data:posts' var='post'>
<b:if cond='data:post.dateHeader'>
<h2 class='date-header'><data:post.dateHeader/></h2>
</b:if>
<b:include data='post' name='post'/>
<b:if cond='data:blog.pageType == "item"'>
<b:include data='post' name='comments'/>
</b:if>
</b:loop>


Now add the following lines of JavaScript code immediately after that.

<script type='text/Javascript'>
&lt;!--
getElementsByClassName("posthidden")[0].className = "postshown";
getElementsByClassName("showhidelink")[0].innerHTML = "";
-->
</script>


And finally we have to make a slight modification to the peek-a-boo hack by adding a showhidelink class to the [+/-] show/hide this post anchor tag.

Search for this tag:
<a expr:href='"javascript:expandcollapse(\"" + data:post.id + "\")"'>


and replace it with
<a class='showhidelink' expr:href='"javascript:expandcollapse(\"" + data:post.id + "\")"'>


Thats it, you're done!

However, for this trick to work, scripting needs to be enabled else the visitor will see the first post hidden just like the previous hack.

This trick can be similarly applied to the Expandable post summaries hack. I shall write about implementing this trick with that hack sometime soon.

I believe a lot can be improved upon this hack too! May be there is a better way to do it. This was just what I came up with. If you have a better solution do hash out!
» Continue reading

Read more on , ,

Where do I find free templates for my blog?

Free Professional Blog Templates for Blogger (Blogspot), WordPress, Windows Live Spaces (MSN Spaces), MySpace, LiveJournal, Typepad, Movable TypeA lot of bloggers have recently asked me for nice design templates for their blogs, especially after the recent change in design of HashOut. Some have even gone to the extent of asking me to replicate the design on their blog. However, I would prefer to maintain a distinct identity for this blog and would not like to share the HashOut template.

I would rather give you some links to resources from where you can get templates for your blogs, free!

If you're on the (old or new/beta) blogger platform Gecko&Fly will be your one stop resource for professional templates. Most designs are re-engineered from popular WordPress templates. ¥€$ also has a neat collection of classic blogger templates categorized according to colors, layout type, background type etc.

If you're on WordPress, here are some links for you:



If you don't mind paying a little for a really professional design for your blog you can check out Damsels of Design. They even have free (linkware) templates which requires you to have a link back to Damsels of Design on your blog.

Lastly, if you want a distinct identity for your blog and if you have Photoshop running on your machine you can check out PHOTOSHOPSUPPORT.com to help you design your own graphics for your blog.

If you have a suggestion to make or a link to a resource that readers will find helpful in designing the layout of their blog, do HashOut!
» Continue reading

Read more on , ,

How to insert Google Adsense ads before or after each post in the new version of Blogger?

If Ad revenue is crucial to your blog then the best place to display your ads is within the main contents of your website or blog as that is what the visitors came looking for. Secondly, it should be "above the fold", i.e. on the visible portion of the page when the page is first loaded as most users don't even scroll down to read the entire post.

In this post I will show how to insert ads after each post title and before the post body (content) in the new version of Blogger. You do not have to insert the code manually into each of the posts. All you have to do is insert the code once into the template. The AdSense server will then automatically display the first three AdSense ad units on the page and there won't be any violation of the TOS too!

Here are the steps:

Note: Before you proceed with any template modifications, it is always a good idea to take a backup copy of your template so that you are safe just in case you or the Blogger server goofs up.


  1. Sign in to the new Blogger
  2. Click on Layout under the Manage: section of one of your blogs. Or click Template if you are already on Posting or Settings tab
  3. Click Edit HTML
  4. Click Download Full Template in order to make a backup of your template on your hard-disk drive.
  5. Click to check the Expand Widget Templates checkbox
  6. Now search for the following line in your template:

    <p><data:post.body/></p>

    and insert the AdSense 336 x 280 Large Rectangle code just before the line as shown below:

    <script type="text/javascript">&lt;!--
    google_ad_client = "pub-YOURPUBLISHERIDHERE";
    google_ad_width = 336;
    google_ad_height = 280;
    google_ad_format = "336x280_as";
    google_ad_type = "text_image";
    google_ad_channel = "";
    //--></script>
    <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    <p><data:post.body/></p>

    Replace YOURPUBLISHERIDHERE with your AdSense publisher ID. To find out your publisher id, sign in to your Google AdSense account, click My Account tab and check AdSense for Content under Property info section.
  7. Hit SAVE TEMPLATE.
  8. You're done! Now take a look at your blog.
» Continue reading

Read more on , , , ,

Peek-a-boo post body contents-hack for New Blogger

The original Blogger hack for show/hide links for posts only deals with the classic template. The same hack can be modified a little to implement it on the new Blogger layout template. Here is the step by step procedure.

Note: Before you proceed with any template modifications, it is always a good idea to take a backup copy of your template so that you are safe just in case you or the Blogger server goofs up.


  1. Sign in to the new Blogger
  2. Click on Layout under the Manage: section of the blog you want to implement this hack on. Or click Template if you are already on Posting or Settings tab
  3. Click Edit HTML
  4. Click Download Full Template in order to make a backup of your template on your hard-disk drive.
  5. Click to check the Expand Widget Templates checkbox
  6. Paste the following two lines into your style sheet i.e. anywhere in between the <b:skin> and </b:skin> tags:

    .posthidden {display:none}
    .postshown {display:inline}

  7. Add the following code to your template, anywhere between the <head> and </head> tags:

    <script type="text/Javascript">

    function expandcollapse(postid) {

    whichpost = document.getElementById(postid);

    if (whichpost.className=="postshown") {
    whichpost.className="posthidden";
    }
    else {
    whichpost.className="postshown";
    }
    }
    </script>

  8. Now search for the following lines in your template:

    <div class='post-body'>
    <p><data:post.body/></p>
    <div style='clear: both;'/> <!-- clear for photos floats -->
    </div>

    and replace them with the following lines:

    <span class='posthidden' expr:id='data:post.id'>
    <div class='post-body'>
    <p><data:post.body/></p>
    <div style='clear: both;'/> <!-- clear for photos floats -->
    </div>
    </span>
    <a expr:href='"javascript:expandcollapse(\"" + data:post.id + "\")"'>
    [+/-] show/hide this post</a>

  9. Hit SAVE TEMPLATE.
  10. You're done! Now take a look at your blog.


An alternative to the show/hide method is to use post summaries. Each method has its own advantages and disadvantages. The advantage of this method to expandable post summaries is that only the template needs to change, with no modification required for your posts. However, you can only display the post titles using this method and it is applied to all posts leaving you with no choice to apply it selectively to long posts only.
» Continue reading

Read more on , ,

How to create expandable post summaries with the new Blogger?

Dexter wants to know how I created the "» Continue reading" links on the non-post pages to make the length of my posts shorter on the index and archive pages so that the readers can have a quick glance at the posts and click "» Continue reading" if they decide to read the complete post. With this trick, you can choose to display an arbitrary amount of text from any part of the post you desire to display. It is quite useful, especially on archive pages, where you have lots of long articles all on one page. This feature requires you to have post pages enabled.

Blogger's original instructions for expandable post summaries to the old Blogger template and Beta (now new Blogger / Blogger v.2) template is available here. However, that page is not without any faults and omissions like the other google.com pages, which are published in haste.

In Step 1: Conditional CSS (for layouts)

New Blogger templates or Layouts do not have a style-sheet by default. The styles are enclosed within the <b:skin></b:skin> tags. It is not possible to add the conditional <b:if cond='data:blog.pageType == "item"'><b:else/></b:if> tags within the skin tags. You have to add the conditional CSS within <style></style> tags outside the skin tags. Simply insert the following lines anywhere between the <head></head> tags.


<style>
<b:if cond='data:blog.pageType == "item"'>
span.fullpost {display:inline;}
<b:else/>
span.fullpost {display:none;}
</b:if>
</style>


Please note that using this hack will just reduce the amount of information that is displayed on the screen. The full content of the posts is still downloaded to the Web browser and available behind the screens (view page source) which means that there won't be any improvement in the download speed of the page. If you know of a hack that can help reduce the download speed of the index and archive pages by omitting the unwanted part of the posts from the page source, then please do hashout!
» Continue reading

Read more on , ,