Add Technorati tags to WordPress posts

technorati_tags.png

There are several WordPress plug-ins that allow to add Technorati tags at the end of your posts. In my experience with WordPress plug-ins, I tend to prefer the simpler ones for an elementary reason: usually reliability is inversely proportional to complexity 😉

On this basis I chose SimpleTags. SimpleTags allows to manage TAGS directly inside the WordPress editor: it’s possible to add tags as a list at the end of the post (syntax [tags ]…[/tags ], without spaces before the closing square brackets) or define TAGS progressively using the post’s content (with the syntax [tag ]example[/tag ], without spaces before the closing square brackets).

To improve the appearance of the results, you need to make little modifications to the plug-in code and the WordPress template.

Open simpletags.php with a text editor (possibly with syntax highlight support): you should see these two lines of code just after the initial comments

$pre_replacement = '<p> Technorati Tags: ';
$post_replacement = '</p>';

You need to modify the variable $pre_replacement in order to add a class to the generated “Technorati Tags” paragraph:

$pre_replacement = '<p class="tag_technorati"> Technorati Tags: ';
$post_replacement = '</p>';

Now you have to save the image used for the icon in the images folder inside the current template and add this rule to the style sheet:

.tag_technorati {
background: transparent url(images/technorati.gif) no-repeat scroll left center;
padding: 8px 2px 8px 20px;
}

Obviously, if you want you can also modify the variable $pre_replacement to create a DIV instead of a paragraph.

Technorati Tags: , ,

Dell XPS M1330 and ship date

xps.png

As I wrote in my first post, I’ve ordered a Dell XPS M1330 about a week ago (June, 29th). This is the configuration I chose:

  • Intel Core 2 Duo T7300(2 Ghz, 4MB cache L2, FSB 800 Mhz)
  • Windows Vista Business
  • 3 years warranty NBD
  • 13,3″LED display with webcam (on the Italian site you can’t choose the display without webcam)
  • 2 GB RAM DDR2 667Mhz (2×1GB)
  • hard-disk SATA 160GB 5400rpm
  • nVidia® GeForce™ Go 8400M GS with 128 MB GDDR3 memory
  • 9 cell battery 85Wh
  • Bluetooth
  • mini Intel® Pro/Wireless 3945 802.11a/b/g
  • nylon thin case, 56k external usb modem

Final price, thanks to an interesting discount by the sale manager, is about 1.500€ (2.050$) without 20% of IVA, corresponding to VAT in Italy.

My notebook is in pre-production from 06/30/2007, estimated ship time 07/20/2007. As you can read in this forum thread (36 pages now!), most of the estimated ship times are in august or september: two months is a long time to wait 😉

Technorati Tags: ,

Self made tag cloud for WordPress

In this tutorial I will show you how to create a simple tag cloud with WordPress categories and place it in your sidebar without using external plug-ins or widgets (you can read here an Italian article about the same argument).

You can write the following code inside the sidebar.php file in your template, or create a new file (tagcloud.php) and include it in your sidebar.php: the second way is better if you have multiple sidebar files.

Let’s start with the second solution: create a file tagcloud.php and place it in your template folder. This is the code you have to write inside this file (you can download tagcloud.php in text format here):

<?php
 
// Extract categories from database
$qrystr = "SELECT cat_ID, cat_name, category_count from $wpdb->categories ORDER BY cat_name";
$cats = $wpdb->get_results($qrystr);
 
// Find the max number of posts for a single category
$max_value = 0;
 
foreach ($cats as $cat)
{
 if ($max_value < $cat->category_count) {
	$max_value = $cat->category_count;
 }  	
}
 
// If you want to change the appeareance of the tag cloud (maximum and minimum percentage in font-size, percentage difference between levels), change only these 3 variables
 
$min_percentage = 80;
$max_percentage = 200;
$percentage_level = 10;
 
$num_levels = ($max_percentage-$min_percentage)/$percentage_level;
$postgap = $max_value / $num_levels;
 
// Display all categories inside a div with id=cloud
// Assign a class to the category (or categories) with more posts
// Do not show categories without posts
 
echo '<div id="cloud">';
foreach ($cats as $cat)
{
 if ($cat->category_count>0) {
  $catname = $cat->cat_name;
  $catlink = get_category_link($cat->cat_ID);
  $postcnt = $cat->category_count;
  $fontsize_percentage = $min_percentage+(Round($postcnt/$postgap)*$percentage_level);
  echo '<a href="',$catlink,'"';
  ($postcnt == 1) ? $str_post=' post">' : $str_post=' posts">';  
  if ($fontsize_percentage==$max_percentage) {
	echo ' style="font-size: ', $fontsize_percentage,'%" class="top_category" title="',$postcnt, $str_post;
  }   
  else {
  	 echo ' style="font-size: ', $fontsize_percentage,'%" title="',$postcnt, $str_post;
   }  
  echo $catname,"</a>\r";
 }
}
echo "</div>";	
?>

Let’s take a quick look at the code:

  • I make a query on the WordPress database (table “categories”): results are ordered by category name and we already have all the data we need thanks to the field “category_count”
  • I check all the results to find the maximum number of posts for a single category. This value is stored using the variable $max_value
  • I set the maximum and minimum percentages to use as font-size, percentage difference between levels and the number of posts between two levels (this is why I need $max_value)
  • now I can walk trough the results of the query, generating the html code: I write a simple link, using title to display the number of the posts for each category (so you will see a tooltip), and assign a special class to the top category (or categories)

Now change your sidebar.php to include the tagcloud.php file; obviously you must choose the right point to place it 😉

At this point you should already be able to see the tag cloud in your blog: the next step is to style it using css. This is the stylesheet I use for this blog:

div#cloud {
	border: 1px dotted #E4F0DB;
	padding: 0.5em;
	margin: 0.6em 0.5em;
	font-family: Tahoma, Verdana, Arial;
	text-align: justify;
	line-height: 1.7em;
}
 
div#cloud a {
	color: #2f63b3;
}
 
div#cloud a.top_category {
	color: #76b391;
}
 
div#cloud a.top_category:hover {
	color: #4A5265;
	text-decoration: none;
}

That’s all 😉

Technorati Tags: ,

Here we go

This is the first post on my brand new blog: Yet Another Tech Blog.

My name is Francesco, I’m a 30 years old Italian guy and I work as a self employed IT consultant in the north of Italy: I provide hardware/software support to small business customers on Windows desktop platforms and I do a little of web and software development.

I’m not new to web-logs: I’ve been writing on my italian blog for almost three years now, but this is my first attempt to write a blog in English.

Why in English? Italian is a great language, but the audience is quite limited: with this blog I hope to reach new (and different) readers. Also, since my English skills are far from good, this blog would be a sort of training area: if you find errors (and you will find a bunch of them), feel free to comment and point them out 😉

So, what will you find in this blog? Since I’m a technology whore, you will read a lot of posts about technology stuff: I own 8 computers (both Mac and pc) and I’ve just ordered a new Dell XPS M1330 (on june, 29th). I’m also an amateur photographer (this is my Flickr account) and an Open Source fan: I’m responsible for the italian localization of Mozilla-Europe and Mozilla Add-ons sites, Mozilla.com start pages, I collaborate on the Italian localization of Firefox and Thunderbird, I’m an administrator of the italian Mozilla support forum and one of the founders of the eXtenZilla project.
Maybe you will also read some thoughts about Italy and Italian life.

Technorati Tags: