WP Cumulus (Tag Cloud)

Every once in a while a user asks me how to change something in WP-Cumulus that fits his or her specific needs. If enough people ask for the same thing (*), it’ll probably be in the next release, but sometimes the modification is so specific to a certain website or project that it makes sense to simply hack it in. Here are the five most common of those, in no particular order.

1. From a sphere to an ellipse
I love spheres. More than I love ellipses. But that’s personal preference. If you really need to have an elliptical tag cloud, here’s how to go about it.
1. Download the development version and open the project in Flash (CS2 or better).
2. Open the Tagcloud.as file,and look for this line: mcList[j].x = rx3 * per;.
3. Change to: mcList[j].x = 5 * rx3 * per;.
4. Publish the movie, and use the resulting swf to overwrite the original one.
This should make the cloud five times wider. You can of course edit the number to suit your needs or do something similar to the y coord. Please note that the movie was designed to fit the round cloud into the available space. Making it five times wider when the width is the limiting dimension will make the tag go way off the screen. You’ll need to adjust the aspect at which you embed the movie to match your modification.
2. Opening links in a new window or tab
As far as the W3C is concerned, target=”_blank” is on the way out, and within WordPress it makes sense to use the same window. If you however need your links to open in a new window, or a specific frame, this is quite easy to do.
1. Download the development version and open the project in Flash (CS2 or better).
2. In Tag.as, look for _self
3. Change to _parent or the name of the frame you want to use.
4. Publish the movie, and use the resulting swf to overwrite the original one.
3. Passing parameters to wp_list_categories
WP-Cumulus was designed with tags in mind, but it made sense to add categories. This was a little tricky, and I needed to pass a few characters to the template tag that lists the categories. This meant I couldn’t open up the parameters to the users like I did with the parameters for the wp_tag_cloud. But if you really need to exclude a category or limit the number of tags, you can add paramaters to ‘mine’.
1. You’ll need to edit ‘wp-cumulus.php’, so you won’t need Flash.
2. Find the line that calls wp_list_categories.
3. Be sure to leave the parameters that I put in there, but feel free to add yours.
4. Save the file and overwrite it on the server.
4. Filtering out accents
By default, WP-Cumulus supports the Latin character set only. This is due to a limitation in the way Flash handles text, and I won’t be able to really fix this until Flash Player 10 becomes mainstream enough. I’ve written a post on how to add your lanuage’s characters, but another option might be to filter out accents. This apparently helps languages like Polish. PHP has a function that does this, and it’s quite easy to add into the plugin.
1. You’ll need to edit ‘wp-cumulus.php’, so you won’t need Flash.
2. Find this line: $tagcloud = urlencode( str_replace( ” “, ” “, ob_get_clean() ) );.
3. Change to: $tagcloud = urlencode( remove_accents( str_replace( ” “, ” “, ob_get_clean() ) ) );
4. Save the file and overwrite it on the server.
(I’m currently considering adding this to the next version, but this hack is needed for all versions up to and including 1.20)
5. Unhiding the regular tag cloud
Because the plugin uses Flash, I needed to provide some alternate content to users who do not have the plugin, and to search engines. The first few versions simply outputted the same tag cloud as regular HTML, but this caused a few problems. Because SWFObject replaces the alternate content after the page has been fully downloaded and displayed, the page would ‘twitch’. That’s why I opted to hide the tag cloud through CSS as an intermediate solution.
If SEO is really important to you, and you feel the tag cloud plays a vital part, you should probably remove the CSS that hides it.
1. You’ll need to edit ‘wp-cumulus.php’, so you won’t need Flash.
2. Find this bit:

.
3. Change to:

.
4. Save the file and overwrite it on the server.
by Roy Tanck

~ oleh archilis pada Sel, 12 Mei 2009.

 
%d blogger menyukai ini: