tag:blogger.com,1999:blog-8169555420293710197.post-6415283989062817732007-05-23T09:09:00.000-04:002007-08-24T10:13:12.540-04:002007-08-24T10:13:12.540-04:00How To Make An Awesome Tag Cloud!I get a lot of emails asking me about the giant tag cloud hanging out at the top of my site. So many, in fact, that I thought it’d be a great idea to make a post out of it, as a bit of a mini-tutorial. So, without further ado, here’s how to get an awesome tag cloud in the New Blogger (formerly Blogger Beta).<br /><br />(<span style="color: rgb(255, 0, 0); font-weight: bold;">UPDATE 24/08/2007</span><span style="font-weight: bold;">: Obviously there’s no tag cloud up there anymore, since I redesigned the site. I’ve posted a screenshot below of what it used to look like. Click it for a larger version.</span>)<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_nYL8yRi-mHs/Rs7msgYZbqI/AAAAAAAABFI/Y4AOASn0ELQ/s1600-h/tags.gif"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp3.blogger.com/_nYL8yRi-mHs/Rs7msgYZbqI/AAAAAAAABFI/Y4AOASn0ELQ/s400/tags.gif" alt="blogger tag cloud" id="BLOGGER_PHOTO_ID_5102269080138247842" border="1" /></a><br /><span style="font-weight:bold;"><br />Okay, back to the regularly scheduled tutorial</span>.<br /><br />First start a new blog in Blogger. Got one? Cool.<br /><br />Now, navigate in Blogger to Template > Page Elements (clicking Layout from the Dashboard will get you there, too). You’re looking for the screen that says “Add and Arrange Page Elements.” Now, in the sidebar of this representation of your blog, click “Add a Page Element.” You’ll get a nice pop-up with a ton of options. Click <span style="font-weight: bold;">Labels</span>, cause that’s what you want to add, after all. Keep it alphabetical, change the name if you feel like it, and click “Save Changes.”<br /><br />Save your template.<br /><br />Now click over to “Edit HTML.” Definitely a good idea to “Download Full Template” here, to be safe, before you start editing the code. I’ll wait.<br /><br />Backed up? Good. Moving on.<br /><br />Search through your code for a line that looks <span style="font-style: italic;">exactly</span> like this:<br /><pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 90%;"><code>&lt;b:widget id='Label1' locked='false' title='Labels' type='Label'/&gt;</code></pre>The “title” attribute might be different if you changed it in the step above. Otherwise, this is the line you’re looking for.<br /><br />Copy <span style="font-weight: bold;">all</span> of this code below.<br /><pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 90%;"><code>&lt;b:widget id='Label1' locked='false' title='Labels' type='Label'&gt;<br />&lt;b:includable id='main'&gt;<br /><br />&lt;div class='widget-content'&gt;<br />&lt;div id='LabelDisplay'&gt;<br />&lt;/div&gt;<br />&lt;/div&gt;<br /><br />&lt;script language='javascript' type='text/javascript'&gt;<br />function zoomStyle() {<br />var max = 0;<br />var min = 10000;<br />&lt;b:loop values='data:labels' var='label'&gt;<br />if (&lt;data:label.count/&gt; &amp;gt; max)<br /> max = &lt;data:label.count/&gt;;<br />if (&lt;data:label.count/&gt; &amp;lt; min)<br />min = &lt;data:label.count/&gt;;<br />&lt;/b:loop&gt;<br />var display = &amp;quot;";<br />&lt;b:loop values='data:labels' var='label'&gt;<br />var delta = &lt;data:label.count/&gt; - min;<br />var size = 80 + (delta * 100) / (max - min);<br />display = display + &amp;quot;&lt;span style='font-size:" + size + "%'&gt;&lt;a expr:href='data:label.url + "?max-results=100"' style='text-decoration:none;'&gt;&lt;data:label.name/&gt;&lt;/a&gt;&lt;/span&gt; &amp;quot;;<br />&lt;/b:loop&gt;<br /><br />obj = document.getElementById(&amp;#39;LabelDisplay&amp;#39;);<br />obj.innerHTML = display;<br />}<br /><br /><br />zoomStyle();<br />&lt;/script&gt;<br /><br />&lt;b:include name='quickedit'/&gt;<br />&lt;/b:includable&gt;<br />&lt;/b:widget&gt;<br /></code></pre>And paste it <span style="font-weight: bold;">over </span>(on top of, instead of, replacing!) the line you found. Be very careful not to overwrite the &lt;/b:section&gt; that will most likely follow it in your template code.<br /><br />Click preview, and if you’ve done everything properly, you’ll have a sweet tag cloud with links of various sizes based on frequency of occurrence (if your blog is brand new, you’ll need to post in it first to see the code at work).<br /><br />If you don’t want it in your sidebar, go back to the Page Elements page, and move the widget around to wherever you like (different templates set different limits on this, which <span style="font-style: italic;">can</span> be subverted, but that’s beyond the scope of this tutorial - <a href="mailto:kevin@frivolousmotion.com">email me</a> if you want to get hardcore).<br /><br />Enjoy! Get tagging! Post your results in the comments for all to see!<br /><br /><span style="font-size:85%;">(Note: The code up there is a modified version of the Multi-style labels widget written up on <a href="http://hackosphere.blogspot.com/2006/09/multi-style-labels-widget-for-blogger.html">Hackosphere</a>. Credit where it’s due.)</span>Kevin M. Keatinghttp://www.blogger.com/profile/09726133592431977513noreply@blogger.com77