<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>v-nessa.net &#187; ajax</title>
	<atom:link href="http://www.v-nessa.net/tag/ajax/feed" rel="self" type="application/rss+xml" />
	<link>http://www.v-nessa.net</link>
	<description>pink is the new black</description>
	<lastBuildDate>Thu, 31 Mar 2011 21:13:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>How to Make a Sexy Tag Cloud with PHP and MySQL</title>
		<link>http://www.v-nessa.net/2007/02/12/how-to-make-a-sexy-tag-cloud</link>
		<comments>http://www.v-nessa.net/2007/02/12/how-to-make-a-sexy-tag-cloud#comments</comments>
		<pubDate>Mon, 12 Feb 2007 06:59:39 +0000</pubDate>
		<dc:creator>Nessa</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.v-nessa.net/2007/02/12/how-to-make-a-sexy-tag-cloud/</guid>
		<description><![CDATA[Well it seems that everyone has one, and I&#8217;d have to admit that a tag cloud is a good way to spice up your site a little bit. I first thought of this when setting up a friend&#8217;s site&#8230; he wasn&#8217;t using a CMS like WordPress or anything that I could find a quick tag [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.v-nessa.net%2F2007%2F02%2F12%2Fhow-to-make-a-sexy-tag-cloud"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.v-nessa.net%2F2007%2F02%2F12%2Fhow-to-make-a-sexy-tag-cloud&amp;source=nessa421&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://v-nessa.net/images/tag_cloud.gif" rel="lightbox[groupname]" title="Tag Cloud"><img src="http://v-nessa.net/images/tag_cloud.gif" alt="Tag Cloud" align="right" height="189" width="246" /></a>Well it seems that everyone has one, and I&#8217;d have to admit that a tag cloud is a good way to spice up your site a little bit.  I first thought of this when setting up a friend&#8217;s site&#8230; he wasn&#8217;t using a CMS like <a href="http://wordpress.org" title="Wordpress" target="_blank">WordPress</a> or anything that I could find a quick tag cloud plugin for, so I figured I could probably just make my own.  Well, I did and now I shall share it.</p>
<p>This tutorial will show you how to set up a simple tag cloud using PHP and MySQL, with a little bit of Ajax effects<br />
Before we get started, take a quick look at the <a href="http://www.v-nessa.net/cloud/" onclick="NewWindow(this.href,'windowname','300','150','no','center');return false" onfocus="this.blur()">sample cloud</a>.<br />
<span id="more-32"></span></p>
<p><strong><br />
Getting Started</strong></p>
<p>The server requirements to make a tag cloud are minimal.  You will need a new or existing <a href="http://mysql.com" title="MySQL" target="_blank">MySQL</a> database and <a href="http://php.net" title="PHP" target="_blank">PHP4+</a>.  It would also be extremely helpful to have something like <a href="http://www.phpmyadmin.net" title="phpMyAdmin" target="_blank">phpMyAdmin</a> or a MySQL command prompt to create the table.</p>
<p><strong><br />
</strong></p>
<p><strong>Creating the Table</strong></p>
<p>The first thing you need to do is create the database table.  You can do this in either a new or existing database:<br />
<font color="#ff66cc"><br />
<code>CREATE TABLE tags (<br />
id int(11) NOT NULL AUTO_INCREMENT,<br />
PRIMARY KEY(id),<br />
tag varchar(100) NOT NULL,<br />
count int(11) NOT NULL DEFAULT '0'<br />
);</code></font></p>
<p>I ran this query via command line, but it may be easier to use phpMyAdmin or whatever database tool you use.  Basically, this is a simply MySQL command that creates the &#8216;<strong>tags</strong>&#8216; table with three columns: <strong>id</strong>, <strong>tag</strong>, and <strong>count</strong>.  The <strong>id</strong> table is being set to auto-increment, meaning that every time a new entry is added the number will go up by 1.  Depending on how you are implementing your tag cloud, you may want to remove this value if you have trouble adding entries.</p>
<p><strong>Creating the Cloud </strong><br />
Now for the actual code itself.  In this section I will break down the script that fetches the tags from the database and creates a pretty tag cloud.  At the end you will find a full sample script that you can use for reference.</p>
<p><font color="#ff66cc"><code>$db_host = "localhost";<br />
$db_user = "username";<br />
$db_pass = "password";<br />
$db_name = "cloud";<br />
</code><code><br />
mysql_connect($db_host, $db_user, $db_pass) or die(mysql_error());<br />
mysql_select_db($db_name);</code></font></p>
<p>This is the section where you define a few variables and use them to connect to the database.  You wil obviously need to input your database name, username, and password in order to allow the script to connect.</p>
<p><font color="#ff66cc"><code>function tag_info() {<br />
$result = mysql_query("SELECT * FROM tags GROUP BY tag ORDER BY count DESC");<br />
while($row = mysql_fetch_array($result)) {<br />
$arr[$row['tag']] = $row['count'];<br />
}<br />
ksort($arr);<br />
return $arr;<br />
}</code></font></p>
<p>This is the function that grabs the tag information from the database and displays everything in the tag column as an array.  Now to build the cloud:<br />
<font color="#ff66cc"><br />
<code>function tag_cloud() {</code></font></p>
<p><code><font color="#ff66cc">$min_size = 10;</font></code><font color="#ff66cc"><br />
<code>$max_size = 30;</code></font></p>
<p><code><font color="#ff66cc">$tags = tag_info();</font></code></p>
<p><code><font color="#ff66cc">$minimum_count = min(array_values($tags));<br />
$maximum_count = max(array_values($tags));<br />
$spread = $maximum_count - $minimum_count;</font></code></p>
<p><code><font color="#ff66cc">if($spread == 0) {<br />
$spread = 1;<br />
}</font></code><font color="#ff66cc"><br />
<code><br />
$cloud_html = '';<br />
$cloud_tags = array();</code></font></p>
<p><font color="#ff66cc"><code>foreach ($tags as $tag =&gt; $count) {<br />
$size = $min_size + ($count - $minimum_count)<br />
* ($max_size - $min_size) / $spread;<br />
$cloud_tags[] = '&lt;a style="font-size: '. floor($size) . 'px'<br />
. '" class="tag_cloud" href="http://www.v-nessa.net/index.php?s=' . $tag<br />
. '" title="\'' . $tag  . '\' returned a count of ' . $count . '"&gt;'<br />
. htmlspecialchars(stripslashes($tag)) . '&lt;/a&gt;';<br />
}<br />
$cloud_html = join("\n", $cloud_tags) . "\n";<br />
return $cloud_html;</code></font></p>
<p><code><font color="#ff66cc">}</font></code></p>
<p><code><font color="#ff66cc">?&gt;</font></code></p>
<p>Take special note of this code:<br />
<font color="#ff66cc"><br />
<code>class="tag_cloud" href="http://www.v-nessa.net/index.php?s=' . $tag</code></font></p>
<p>In this section I&#8217;m basically telling the script to append the tag name at the end of a link&#8230;in this case it&#8217;s my search path, meaning that clicking on, for instance, the ruby tag will take you to this link:</p>
<p><strong>http://www.v-nessa.net/index.php?s=ruby</strong></p>
<p>This will just take you to a search for the term &#8220;ruby&#8221; on my site, but you can specify how you want the tag name to be incorporated into a link.  For instance:<br />
<font color="#ff66cc"><br />
<code>class="tag_cloud" href="http://www.v-nessa.net/tags/' . $tag</code></font></p>
<p>The above example shows the primary purpose of a tag cloud, which will take the tag pulled from a database and pull all articles under that tag.  An example of this is on the menu of my site, to the right.</p>
<p>The last part of the script should be the style sheet, which will direct how the cloud will look:<br />
<font color="#ff66cc"><br />
<code>&lt;style type="text/css"&gt;<br />
.tag_cloud<br />
{padding: 3px; text-decoration: none;<br />
font-family: verdana;   }<br />
.tag_cloud:link  { color: #FF66CC; }<br />
.tag_cloud:visited { color: #9900FF; }<br />
.tag_cloud:hover { color: #FF66CC; background: #000000; }<br />
.tag_cloud:active { color: #6699FF; background: #000000; }<br />
&lt;/style&gt;</code><br />
</font></p>
<p>To Display the tag cloud, you just need to insert this code into your web page (or sidebar):</p>
<p><font color="#ff66cc"><code> &lt;div id="wrapper"&gt;<br />
&lt;?php print tag_cloud(); ?&gt;<br />
&lt;/div&gt;</code></font></p>
<p>And there you go&#8230;your very own tag cloud.  You&#8217;ll of course need to populate the table with your own tags, ids and count numbers, or plug this script into your blog to fetch the tags from its database.</p>
<p>You can find a full copy of the script <a href="http://www.v-nessa.net/scripts/tag_cloud.phps" title="Tag Cloud" target="_blank">here</a>.</p>
<p><a href="http://tinyurl.com/3cu9zg"><br />
</a></p>
<p><!--adsense#img_banner--></p>
<p><map name='google_ad_map_32_7fa65e237551a74a'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/32?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_32_7fa65e237551a74a' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=32&amp;url= http%3A%2F%2Fwww.v-nessa.net%2F2007%2F02%2F12%2Fhow-to-make-a-sexy-tag-cloud' /></p><img src="http://www.v-nessa.net/?ak_action=api_record_view&id=32&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.v-nessa.net/2007/02/12/how-to-make-a-sexy-tag-cloud/feed</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>Modx Makes Me Drool</title>
		<link>http://www.v-nessa.net/2007/01/25/modx-makes-me-drool</link>
		<comments>http://www.v-nessa.net/2007/01/25/modx-makes-me-drool#comments</comments>
		<pubDate>Thu, 25 Jan 2007 05:27:11 +0000</pubDate>
		<dc:creator>Nessa</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[site design]]></category>

		<guid isPermaLink="false">http://www.v-nessa.net/2007/01/25/modx-makes-me-drool/</guid>
		<description><![CDATA[I never thought I&#8217;d say that about a CMS, but then again I said the same thing about Scott and look what happened there. Anywho, one of my friends showed me this new CMS that is purely Ajax on PHP, and I decided to give it a whirl. I might even switch my site over [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.v-nessa.net%2F2007%2F01%2F25%2Fmodx-makes-me-drool"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.v-nessa.net%2F2007%2F01%2F25%2Fmodx-makes-me-drool&amp;source=nessa421&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><img src="http://v-nessa.net/images/lime.jpg" title="Modx" alt="Modx" align="left" />I never thought I&#8217;d say that about a CMS, but then again I said the same thing about Scott and look what happened there.  Anywho, one of my friends showed me this new CMS that is purely <a href="http://developers.sun.com/ajax/index.jsp?cid=59754" title="Ajax" target="_blank">Ajax</a> on <a href="http://php.net" title="PHP" target="_blank">PHP</a>, and I decided to give it a whirl.  I might even switch my site over once I figure out how it works.</p>
<p><a href="http://modxcms.com/features.html" title="Modx" target="_blank">See it here.</a></p>
<p><map name='google_ad_map_26_7fa65e237551a74a'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/26?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_26_7fa65e237551a74a' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=26&amp;url= http%3A%2F%2Fwww.v-nessa.net%2F2007%2F01%2F25%2Fmodx-makes-me-drool' /></p><img src="http://www.v-nessa.net/?ak_action=api_record_view&id=26&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.v-nessa.net/2007/01/25/modx-makes-me-drool/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

