I have been doing some work on my version of the FreshTags concept. The first major addition is the ability to pull in other FreshTags users’ data for use in the sidebar. If you look at my links sidebar you’ll see a ‘+’ to the left of some items. Only two of these use FreshTags, Freshblog and Ecmanaut. If you click the ‘+’ next to either of these when there is no query tag you will be presented with a list of the newest posts from those blogs. If there is a tag selected, however, you will be presented with a list of posts on those blogs matching that tag, unless they have none in which case the list of newest posts is again presented. The template code to do this (without the show/hide magic) is:
<script type=”text/javascript”>dynamic_delicious_load(‘DELICIOUS USER‘,’ANCHOR TAG‘,function(){write_tagged_posts(false,false,’FEED URL‘);});</script>
The three parameters passed to write_tagged_posts are:
- extendedyes — TRUE to display the contents of the extended field, otherwise FALSE
- hideonnull — TRUE to have blank output if there are no post matches, otherwise FALSE
- feedurl — The URL to the feed for this item, do not pass if you don’t know it or don’t want to display recent items on no match
- max — # limit of posts to display, not shown in example above
The second major addition is to the fetch_query_tag function. If no tag has been passed to the page, and it cannot find one in the referrer URL then it looks in the current page. It grabs the first rel=tag item and uses the contents of that as query_tag. Thus if a tag cannot be found any other way it finds related posts to the current one. The only minor problem with this addition is that including the JavaScript in the header means fetch_query_tag runs before the page has fully loaded, so it will usually not find anything. I solved this by moving the block that includes the main Delicious.posts and the tagspostpage.js to my sidebar, which is after my posts in my code. If your sidebar comes before your posts you’re stuck, because you need it loaded before the sidebar for the list_side_tags function to work. If anyone knows of a way around this I would appreciate knowing.
I was unable to actually hook this to onload (per Johan’s comment) because the data must be loaded before list_side_tags or write_tagged_posts can be run. I found a solution in using the callbacks again, and this time list_side_tags will load tags if they are unloaded when called and same for posts for write_tagged_posts. return_tagged_posts can therefore not be called until one of these others (or you call load_data(‘posts’) yourself), however since the main use of return_tagged_posts is at the end of the code, after write_tagged_posts, for use on the inline tags page, this should not be a problem. So autocapture should now work without modifying your template code to move the javascript stuff from the <haed> section.
If you place code similar to:
<MainPage><script type=”text/javascript”>var no_autocapture = true;</script></MainPage>
in your <head> section it will stop the tag autocapture on your main page (per Richard’s comment)
This hack has been superceded by this better one.
Getting Blogger baclinks to display on your main page is no picnic – wheather for peek-a-boo or permanent display. The way the script works direct from Blogger it assumes that it is running on a post page. So, after mor than a little fussing, I have come up with a hack that works for fixing this. The following will install peek-a-boo backlinks on your Blogger blog (template hackers will be pleased to know that the backlink template-tag section is still intact for your hacking pleasure) :
- Enable backlinks on your blog — an obvious, but necessary, step
- a – Put manual metadata in your template. Feedburner users have already done this. If you already have your metadata in your template manually for this or another reason, change this line:
<script type="text/javascript" src="http://www.blogger.com/js/backlink.js"></script>
To this:
<script type="text/javascript" src="http://www.awriterz.org/etcetc/backlink.js"></script>
Otherwise go on to 2b.
b – Find this : ‘<$BlogMetaData$>‘, it should be somewhere near the top of your blog template. Replace it with this:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="MSSmartTagsPreventParsing" content="true" />
<meta name="generator" content="Blogger" />
<link rel="alternate" type="application/xml" title="<$BlogTitle$>" href="<$BlogSiteFeedUrl$>" />
<link rel="service.post" type="application/atom+xml" title="<$BlogTitle$>" href="https://www.blogger.com/atom;$BlogID$>" />
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://www.blogger.com/rsd.g?blogID;$BlogID$>" />
<style type="text/css">
@import url("http://www.blogger.com/css/blog_controls.css");
@import url("http://www.blogger.com/dyn-css/authorization.css?blogID;$BlogID$>");
</style>
<script type="text/javascript" src="http://www.awriterz.org/etcetc/backlink.js"></script>
<script type="text/javascript" src="http://www.blogger.com/js/backlink_control.js"></script>
<script type="text/javascript">var BL_backlinkURL='http://www.blogger.com/dyn-js/backlink_count.js', BL_blogId='<$BlogID$>';</script>
- Put this code directly after that which you just inserted:
<script type="text/javascript">
//<![CDATA[
function toggleitem (postid,linkid,newtxt) {
var whichpost = document.getElementById(postid);
if (whichpost.style.display != "none") {
whichpost.style.display = "none";
} else {
whichpost.style.display = "block";
}
if(linkid) {
var lnk = document.getElementById(linkid);
lnk.href = "javascript:toggleitem('"+postid+"','"+linkid+"','"+lnk.innerHTML+"');";
lnk.innerHTML = newtxt;
}
}
//]]>
</script>
- Find the section in your template that starts with ‘<BlogItemBacklinksEnabled>‘ and ends with ‘</BlogItemBacklinksEnabled>‘ and replace the entire thing (these tags included) with this code:
<ItemPage><div style="display:block;" id="backlinks<$BlogItemNumber$>"></ItemPage>
<MainOrArchivePage><div style="display:none;" id="bl<$BlogItemNumber$>"></MainOrArchivePage>
<BlogItemBacklinksEnabled>
<a name="links"></a><h4>Backlinks:</h4>
<dl id="comments-block">
<script type="text/javascript">backlink = new Array();BL_Backlinks = new Array();</script>
<script type="text/javascript" src="http://www.blogger.com/dyn-js/backlink.js?blogID;$BlogID$>&postID=<$BlogItemNumber$>" defer="true"></script>
<div id="blogger-dcom-block<$BlogItemNumber<div id="blogger-dcom-block<$BlogItemNumber<div id="blogger-dcom-block<$BlogItemNumber<div id="blogger-dcom-block<$BlogItemNumber<div id="blogger-dcom-block<$BlogItemNumber<div id="blogger-dcom-block<$BlogItemNumber<div id="blogger-dcom-block<$BlogItemNumber<div id="blogger-dcom-block<$BlogItemNumber$>" style="display:none">
amp;gt;" style="display:none">
amp;gt;" style="display:none">
amp;gt;" style="display:none">
<dt class="comment-title">
<span class="comment-toggler"> </span>
<a href="<$BlogBacklinkURL$>"><$BlogBacklinkTitle$></a>
</dt>
<dd class="comment-body"><$BlogBacklinkSnippet$>
<br />
<span class="comment-poster">
<em>posted by <$BlogBacklinkAuthor$> @ <$BlogBacklinkDateTime$></em>
</span>
</dd>
</div>
<script type="text/javascript">BL_writeBacklinks('<$BlogItemNumber$>');</script>
</dl>
<p class="comment-timestamp"><$BlogItemBacklinkCreate$></p>
</BlogItemBacklinksEnabled>
</div>
- Find the code for the ‘links to this post’ link in your post footer template code and replace it with ‘<a href=”javascript:toggleitem(‘backlinks<$BlogItemNumber$>’);”>links to this post</a>‘
- Save your template and republish your blog!