Two moths ago I published a post on how to custom format your Blogger backlinks. The only downside on this script is that your MainOrArchivePage
will appear slow because after each item a small Javascript needs to be loaded from blogger.com. Today I wrote a speed up for this. I now only insert a placeholder span
and do the rest of the needed scripting at the bottom of the page.
Here is the script to place on the MainOrArchivePage
(after the link to the comments for example):
<script type="text/javascript"> //<![CDATA[ document.write('· <a href="<$BlogItemPermalinkUrl$>#links">Links: <span id="BLc<$BlogItemNumber$>">?</span></a>'); if (! BL_BacklinkCount) var BL_BacklinkCount = new Array(); BL_BacklinkCount['<$BlogItemNumber$>'] = document.getElementById('BLc<$BlogItemNumber$>'); //]]> </script>
Here is the script to put at the bottom of your page (after the Blogger
close tag):
<MainOrArchivePage> <script type="text/javascript"> //<![CDATA[ for (var item in BL_BacklinkCount) { document.write('<script type="text/javascript" src="http://www.blogger.com/dyn-js/backlink_count.js?blogID=<$BlogID$>&postID='+ item +'"></scr'+'ipt>'); } //]]> </script> </MainOrArchivePage>
9 comments:
Does the itempage script remain the same? I'm getting "links:?" on my itempages after upgrading to the new main/archive page scripts. Thanks.
John, I don't show the link count on item pages on my blog. If you do want to show the link count on your item pages, you will need to include the second code block somewhere below the first code block on your item pages as well. This second block will overwrite the placeholders (question marks).
I'd like the "Links: #" in the post footer (on the MainorArchivePage) to appear only if there are 1 or more backlinks. If there are no backlinks, I'd like nothing about backlinks to appear in the footer (just as it does not appear on the ItemPage).
is this possible?
Great hack! thanks a lot!
Ah, I figured it out finally. To make it so the "Links: #" only shows up in the post footer if you in fact have backlinks, you need to add some code before the code listed above for the MainOrArchivePage. What you need to add is the first part of the code for the ItemPage--everything up to the first "document.write" command (but not including it), ending with the open bracket {
Then after the MainOrArchivePage code, just close it up with a closing } before the //]]>
That's working now on my blog: Blogging the Renaissance. Thanks for a great hack! Now if only Blogsearch actually picked up all the posts linking to my site...
hi
i added the code to my page. it does show the number of links to certain postings, but it doesn't show the actual pages that are linking to me: blackademic.blogspot.com
what should i do?
nubian,
I don't see the Links actually giving the number, just the ? that it displays while retrieving the number or if it has a problem. I wonder if part of the problem is that you're still also using the standard Blogger backlinks code. I replaced the standard code with this code and it worked really well: bloggingtherenaissance.blogspot.com (also includes the adaptation I mention above, to only display when there are backlinks)
nubian,
I think Blogsearch was having trouble earlier today. Now I see the # of links and I also see the linking posts in your ItemPage. So it seems to be working fine, although it might be less confusing to remove the standard Blogger code for "links to this post" in the post footer.
This entire function seems to go in and out lately. Is Blogsearch having problems? It works fine on my blog, then it disappears completely, then comes back, etc.
Any thoughts?
I decided to try this hack and I see the backlinks link but with a ? or an 0. Also the posts that I know have backlinks still are not showing the backlinks. Could it be because I have an old account? Do old accounts work?
Also, I had gotten the peek-a-boo comments to work but I guess they don't work with backlinks? I have seen one blog that had this for both but could not figure out how to make the backlinks work.
Post a Comment