Wednesday, February 07, 2007 :
Blogger
The archives for this page used to be on a separate page, listed by month. This page had a separate template within Blogger and was automatically updated by the Blogger CMS. However, since the transition to “New Blogger” in 2007, it appears that, without fanfare, Blogger have withdrawn this functionality. The monthly archive pages themselves were still being created (eg January 2007) but the index page was not being updated. This is because most people on Blogger are using the Blogger standard templates, which feature archives on the sidebar of the main page, rather than on a separate page, as was more commonly the case in the old days. It took me some time and a lot of google searching to find this out and figure out why the archive index page was stubbornly refusing to update notwithstanding that everything else seemed to be working properly.
The work–around is a toggle in the sidebar. This itself presented a number of difficulties. My sidebar is an SSI and you cannot call the <Blogger> tags to generate the archive list from it, because they can only be called from within the Blogger template that generates the main page. Therefore, I had to put the <Blogger> tags somewhere in the main template (under the “want more?” link at the bottom of the page) and encase them in a <div> tag, from which I could then extract the Blogger generated html listing the archives for repetition in my sidebar by using the getElementByID() method. A second problem then arose. Because the sidebar appears on pages other than the page which contains the main blog (and therefore the <div> containing the archives), an error obviously occured when the sidebar code was trying to extract and repeat something which was not there. The solution was to run an if/else statement, so that the extraction was only attempted where there was something to extract. The sidebar code is as follows:
<a href="/" onclick="toggle('bararchives');return false;" title="Hide or show archives below">Archives</a><div id="bararchives" style="display:none;"><script type="text/javascript">
if (document.getElementById("archives"))
{
var x=document.getElementById("archives");
var y=(x.innerHTML);
document.writeln(y);
}
else
{document.writeln('archives can only be accessed from <a href="http://www.foxinternet.co.uk">main page</a>')
}
</script>
</div>
The toggle() function that is called onClick() within the above is a function that I had already coded in order to toggle the blogroll.
Thank you, Blogger, for giving me this small challenge to enliven my otherwise dull existence.
want more?