1

I'd like to create a tag clouds, and I'm wondering based on what parameters I should do this.

Also, I don't want the same top tags to be displayed all the time, so how do big sites handle this?

I've got table that contains the items, a table that contains the tags (just tag id and tag text) and another table for normalization, with a row for each relationship between an item and a tag.

1
  • 1
    It's better to google it and check results. If you have questions about implementation, ask these questions at SO/Programmers. Commented Nov 23, 2011 at 22:01

1 Answer 1

1

I think a good implementation with nice flexibility (and in PHP) is WordPress's implementaion. Have a look at their argument object in the documentation for wp_tag_cloud():

  • smallest - The smallest tag (lowest count) is shown at size 8
  • largest - The largest tag (highest count) is shown at size 22
  • unit - Describes 'pt' (point) as the font-size unit for the smallest and largest values
  • number - Displays at most 45 tags
  • format - Displays the tags in flat (separated by whitespace) style
  • separator - Displays whitespace between tags
  • orderby - Order the tags by name
  • order - Sort the tags in ASCENDING fashion
  • exclude - Exclude no tags
  • include - Include all tags
  • *topic_count_text_callback* - Uses function default_topic_count_text
  • link - view
  • taxonomy - Use post tags for basis of cloud
  • echo - echo the results

That's with this code as a sample:

<?php $args = array(
    'smallest'                  => 8, 
    'largest'                   => 22,
    'unit'                      => 'pt', 
    'number'                    => 45,  
    'format'                    => 'flat',
    'separator'                 => \"\n\",
    'orderby'                   => 'name', 
    'order'                     => 'ASC',
    'exclude'                   => null, 
    'include'                   => null, 
    'topic_count_text_callback' => default_topic_count_text,
    'link'                      => 'view', 
    'taxonomy'                  => 'post_tag', 
    'echo'                      => true ); ?>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.