LineBuzz Wiki  |  FAQ  |  Blog  |  Sign in to LineBuzz  
LineBuzz - Inline Blog Comments
Get LineBuzz
...elseif ($catweight < .02) $tagweight = \...
Inline Comment posted on "The K-log" 18 months 25 days ago.

An Inline Comment was posted on the text below
Scroll down for the comments

“something i’ve been wanting to do for a while is shift from the boring and overwhelming list of categories on my sidebar to a tag cloud in the ultrahip web 2.0 folksonomic tradition. this is not because i aspire to be hip like three snaps in a 2(.0) formation, but because i think clouds are a good idea. i like clouds because: they have more information in them than lists (size is information!). they are prettier than lists. they take up less room than lists. they are where the care bears live. what’s not to love? once upon a time, in a spurt of energy to this end, i downloaded and installed the formidably named Ultimate Tag Warrior plugin, which promises nifty tag cloud goodness for all, but which ended up requiring too much of me in order to realize such goodness, so i let it drop. i think i was frustrated because i knew deep down that it was not a very complicated problem, but it was still too much for me to think about on any one given day, so i ignored it for a silly long time. therein languish so many of the ills of this world… but today i prevailed! go look! (you have to be on the main page, not viewing just this post) heeeheehee!!! and if you don’t want to hear anything geekier than that, you should stop reading, because now i’m gonna talk about code and stuff. so consider yourself warned. i decided to search around again for options and advice, and i found very fruitful beginnings in: this blog entry wherein the code professor churns out some wordpress-ready php for cloud-building, he being inspired in turn by the technology evangelist writing about using php and css to build tag clouds for movable type blogs. i liked the approach suggested by them because the core idea for wordpress is simple: 1) replace the part of the sidebar.php file that goes to fetch the category list with your own code that makes a tag cloud. 2) size appropriately using css. once i thought about this, installing a plugin for the task felt silly and much less fun, so i was inspired to follow their trail. the php as provided went through the trouble of counting the number of posts in each category even though wordpress provides a function for that, but then someone in the comments pointed that out and offered some new code, so that was nice. the css was taken from the technology evangelist as written, and i didn’t really like it. it basically assigned each tag an id based on the number of posts in the category and then sized the tags based on that number, which is reasonable in theory except in practice it led to css brackets like this: a.tag4 ,a.tag5, a.tag6 { font-size:16px; font-weight:300; } for each triad of numbers up to 30. and apparently it just expects that no category will have more than 30 posts. this seems short-sighted to me, particularly because if you were a somewhat balanced category user and you blogged for a number of years you would eventually get to the point where almost all of your tags were the same size. which defeats the purpose. and sure you could go in as you wrote more and change the numbering scheme, but who wants to do that? it makes more sense to me to size each category based on the percentage of total posts. in the beginning all your tags would be big because each post would be a large percentage of the total, but it seems like it would equalize out pretty quick, and then scale well with time. the only downside is that it requires you to count all the posts, and writing another loop for that seemed a little excessive. i did a little more searching and found this, which offers a php function that will get the total number of posts for you. apparently people want to do that somewhat often, but wordpress doesn’t support it directly. yet. but i still love them. anyway, here is the code that i ended up with after mashing those bits and pieces together and fiddling with dangling quotation marks and asking david for some help because he conveniently appeared on IM right when i was having an issue. thanks, david! if you are running wordpress and want a tag cloud like mine, open your sidebar.php file (it’s in wp-content/themes/youractivetheme), find the part that looks like this: <ul/> <?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=0'); ?/> </ul/> and replace it with this: <?php // Grab category info from the database table wp_categories $qrystr = \ elseif ($catweight < .02) $tagweight = \ ; elseif ($catweight < .1) $tagweight = \”


 by Erik 18 months 25 days ago at "The K-log".
This sort of thing is a surefire sign that an array is needed.


Other LineBuzz conversations from "The K-log":
  1. elseif ($catweight < .02) $tagweight = \
  2. they are where the care bears live.
Other LineBuzz conversations that might interest you:
  1. nethack
  2. To post an inline comment, use your mouse to highlight text.
  3. \
  4. Tony Wright
  5. threatened to make this switch months ago
  6. World Bank
  7. download that book for absolutely no cash
  8. It will define the venues we build
  9. 2006 WikiSym conference in Denmark
  10. sold out
LineBuzz Changelog   |   LineBuzz Wiki   |   FAQ   |   Terms of Use   |   Privacy   |   LineBuzz Blog

© 2007 LineBuzz.com