<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
   <title>Posts by Andrey Serebryakov on Learning Movable Type</title>
   <link rel="alternate" type="text/html" href="http://www.learningmovabletype.com/" />
   <link rel="self" type="application/atom+xml" href="http://www.learningmovabletype.com/contributors/saahov/" />
   <id>tag:,2008-02-25:/5</id>
   <updated>2007-10-26T06:33:42Z</updated>
   <subtitle>Tutorials and helpful tips for the Movable Type web publishing system</subtitle>
   <generator uri="http://www.movabletype.org/">Movable Type Publishing Platform 4.01</generator>

<entry>
   <title>Tag Cloud on PHP in Movable Type 4</title>
   <link rel="alternate" type="text/html" href="http://www.learningmovabletype.com/a/tag_cloud_on_php_in_movable_type_4/" />
   <id>tag:www.learningmovabletype.com,2007://5.1848</id>
   
   <published>2007-10-25T06:30:10Z</published>
   <updated>2007-10-26T06:33:42Z</updated>
   
   <summary>Movable Type has become one of the first platforms in which tags have appeared . It happened in the third version. And in the fourth version it is possible to add tags not only to post, but also to uploaded files or created pages. But functionality of the tag MTTags...</summary>
   <author>
      <name>Andrey Serebryakov</name>
      <uri>http://saahov.ru/</uri>
   </author>
   
      <category term="PHP" scheme="http://www.sixapart.com/ns/types#category" />
   
      <category term="Tags" scheme="http://www.sixapart.com/ns/types#category" />
   
   <category term="mt4" label="MT4" scheme="http://www.sixapart.com/ns/types#tag" />
   <category term="php" label="PHP" scheme="http://www.sixapart.com/ns/types#tag" />
   <category term="phpinclude" label="PHP Include" scheme="http://www.sixapart.com/ns/types#tag" />
   <category term="sidebar" label="Sidebar" scheme="http://www.sixapart.com/ns/types#tag" />
   <category term="tagcloud" label="Tag Cloud" scheme="http://www.sixapart.com/ns/types#tag" />
   <category term="tags" label="Tags" scheme="http://www.sixapart.com/ns/types#tag" />
   <category term="templates" label="Templates" scheme="http://www.sixapart.com/ns/types#tag" />
   
   <content type="html" xml:lang="en" xml:base="http://www.learningmovabletype.com/">
      <![CDATA[<p>Movable Type has become one of the first platforms in which tags have appeared . It happened in the third version. And in the fourth version it is possible to add tags not only to post, but also to uploaded files or created pages. But functionality of the tag MTTags is not thought over up to the end in the current version as well as in the previous version MT. It is necessary to make some efforts to have a normal Tag Cloud.</p>]]>
      <![CDATA[<p><strong>In the third version</strong> it was possible to deduce the list of all tags, excepting an opportunity of restriction of their numbers. The cloud was expected to turn out. When tags became more, they turned into a cloud and occupied the most part of the screen.  </p>
<p></p>
<p><strong>In the fourth version</strong> an opportunity has been added to establish the&nbsp;numbers of&nbsp; displayed tags, and also their sorting by ranks. Now on the site it's possible to show a cloud&nbsp; which will include 50 of the most popular tags. The&nbsp;numbers of tags in a cloud is set individually, but such opportunity pleases. But there&rsquo;s an ill luck: when sorting by ranks tags are displayed in this way &mdash;&nbsp;the more popular the tag is, the higher it will be, or on the contrary. A simple example:</p>
<p></p>
<p><span class="mt-enclosure mt-enclosure-image"><img alt="Tag Cloud on Movable-Type.ru" src="http://www.learningmovabletype.com/image/mt_ru_tags_cloud.png" width="199" height="203" class="mt-image-center" style="text-align: center; display: block; margin: 0 auto 20px;"/></span></p>
<p>It does not suit at all as the visual perception of such cloud does not cause any desire to click under the link. Therefore it is necessary to resort to PHP&rsquo;s help.</p>
<p></p>
<p><strong>Create Normal Tags Cloud</strong></p>
<ol>
<li>First of all you must change extension of files on .php. For this just go to the <strong>settings</strong> of the blog, then to the tab &ldquo;Publishing&rdquo;. Enter &ldquo;php&rdquo; near by the item &ldquo;File Extension for Archive Files&rdquo; (without a point in the beginning). After that all archives (posts, categories, pages, etc) will be published with new extension. But some index files, for example, Main Index and Archives, will stay with old extensions. Therefore you will have to go to the section <strong>Templates</strong> and manually specify the necessary extension for these templates.</li>
<li>Then it is necessary to create an index tempalate (we call it <strong>TagCloud</strong>, with a name of the published&nbsp; file <strong>tagcloud.php</strong>) which will be automatically published with the following contents:<br /><br /><code><pre>&lt;?<br />&nbsp; $tagslist = array(&lt;MTTags limit="50" sort_by="rank" glue=", "&gt;"&lt;$MTTagName$&gt;" =&gt; &lt;$MTTagRank max="10"$&gt;&lt;/MTTags&gt;);<br />&nbsp; ksort($tagslist);<br />&nbsp; reset($tagslist);<br />&nbsp; while (list($tag, $tagsize) = each($tagslist))<br />&nbsp; {<br />&nbsp;&nbsp; echo '&lt;a href="http://example.com/tag/'.rawurlencode($tag).'" class="t'.$tagsize.'" rel="tag"&gt;'.$tag.'&lt;/a&gt;';<br />&nbsp;&nbsp; echo "\n";<br />&nbsp;&nbsp; }<br />?&gt;</pre></code><span class="mt-enclosure mt-enclosure-file"><a href="http://www.learningmovabletype.com/image/tagcloud.zip">Download the example with the comments</a></span>.<br /></li>
<li>If you want template TagCloud to be displayed on other pages of the site you should include it in these pages. It is made with the help of function include in PHP:<br /><br /><code><pre>&lt;? include ("/home/user/example.com/template-path/tagcloud.php");  ?&gt;</pre></code><br />If&nbsp; you have standard templates this line is necessary to be set in a Sidebar template (&ldquo;Sidebar (3-column)&rdquo; or &ldquo;Sidebar (2-column)&rdquo;). Find a code &lt;MTTags limit ="20" sort_by ="rank"&gt; finishing with &lt;/MTTags&gt;. Delete it and interchange it with a line from the third point. Pay attention that you must&nbsp;&nbsp;specify an absolute way to a template. You can learn about if you look in the blog settings.</li></ol>
<p>Well that&rsquo;s all, now you should have normal Tags Cloud or something like this:</p>
<p><span class="mt-enclosure mt-enclosure-image"><img alt="Tag Cloud on ProBlog.ru" src="http://www.learningmovabletype.com/image/problog_tags_cloud.png" width="235" height="482" class="mt-image-center" style="text-align: center; display: block; margin: 0 auto 20px;"/></span><strong><br />Reference Links</strong></p>
<ul>
<li><a href="http://www.sixapart.com/movabletype/beta/2006/06/everybody_loves_tags.html">Everybody loves tags!</a><font color="#000000"><br /></font>Look at the point &ldquo;Beautifying the tag search link URLs&rdquo; and learn how to make beautiful URL for tags.</li></ul>
<p><em>Thanks Zara Khudaverdyan for the help in translation of tutorial into English language.<br /><a href="http://movable-type.ru/2007/10/tagscloud-php.php">This tutorial on Russian language.</a></em></p>]]>
   </content>
</entry>

</feed>

