Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP] Tag Cloud
Forum PHP.pl > Forum > Przedszkole
allex
Witam. Znalazłem w sieci skrypt do wyświetlania tgz. Tag Cloud na stronie ale nie bardzo mi chce działać.
  1. <?PHP
  2. function get_tag_data() {
  3. $arr = Array('Actionscript' => 35, 'Adobe' => 22, 'Array' => 44, 'Background' => 43, 
  4. 'Blur' => 18, 'Canvas' => 33, 'Class' => 15, 'Color Palette' => 11, 'Crop' => 42, 
  5. 'Delimiter' => 13, 'Depth' => 34, 'Design' => 8, 'Encode' => 12, 'Encryption' => 30, 
  6. 'Extract' => 28, 'Filters' => 42, 'Flash' => 32, 'Functions' => 19, 
  7. 'Gaussian Blur' => 44, 'Grafix' => 49, 'Graphics' => 35, 'Hue' => 47, 'Illustrator' => 8, 
  8. 'Image Ready' => 12, 'Javascript' => 47, 'Jpeg' => 15,  'Keyboard' => 18, 'Level' => 28, 
  9. 'Liquify' => 30, 'Listener' => 10, 'Logo' => 12, 'Loops' => 22, 'Macromedia' => 26, 
  10. 'Method' => 28, 'MySQL' => 18, 'Obfuscation' => 13, 'Object' => 39, 'Optimize' => 25, 
  11. 'PDF' => 37, 'PHP' => 44, 'PSD' => 17, 'Photography' => 28, 'Photoshop' => 46, 
  12. 'Revert' => 50, 'Saturation' => 35, 'Save as' => 28, 'Scope' => 11, 'Scripting' => 9, 
  13. 'Security' => 41, 'Sharpen' => 49, 'Switch' => 41, 'Templates' => 11, 'Texture' => 22, 
  14. 'Tool Palette' => 30, 'Variables' => 50);
  15. return $arr;
  16. }
  17. function get_tag_cloud() {
  18. }
  19. $min_font_size = 12;
  20. $max_font_size = 30;
  21.  
  22.  
  23. $tags = get_tag_data();
  24.  
  25. $minimum_count = min(array_values($tags));
  26. $maximum_count = max(array_values($tags));
  27. $spread = $maximum_count - $minimum_count;
  28.  
  29. if($spread == 0) {
  30. $spread = 1;
  31. }
  32. $cloud_html = '';
  33. $cloud_tags = array();
  34. foreach ($tags as $tag => $count) {
  35. $size = $min_font_size + ($count - $minimum_count) 
  36. * ($max_font_size - $min_font_size) / $spread;
  37. $cloud_tags[] = '<a style="font-size: '. floor($size) . 'px' 
  38. . '" class="tag_cloud" href="http://www.google.com/search?q=' . $tag 
  39. . '" title="'' . $tag . '' returned a count of ' . $count . '">' 
  40. . htmlspecialchars(stripslashes($tag)) . '</a>';
  41. }
  42. $cloud_html = join("n", $cloud_tags) . "n";
  43. return $cloud_html;
  44. ?>

Czy ktoś wie co jest z nim nie tak?
Ociu
A co się dziej ? Różowe słonie latają po stronie ?
allex
Nie! Fruwają białe myszki. Właśnie o to chodzi, że nic się nie dzieje i nic nie wyświetla!!
Ociu
Ale masz odlot, mi nigdy białe myszki nie latały po stronie :/
daj print_r($tags);
i przed join" title="Zobacz w manualu PHP" target="_manual daj print_r($cloud_html);

Sory, oczywiście chodziło o $cloud_tags.
devnul
  1. <?php
  2. function get_tag_data() {
  3. $arr = Array('Actionscript' => 35, 'Adobe' => 22, 'Array' => 44, 'Background' => 43, 
  4. 'Blur' => 18, 'Canvas' => 33, 'Class' => 15, 'Color Palette' => 11, 'Crop' => 42, 
  5. 'Delimiter' => 13, 'Depth' => 34, 'Design' => 8, 'Encode' => 12, 'Encryption' => 30, 
  6. 'Extract' => 28, 'Filters' => 42, 'Flash' => 32, 'Functions' => 19, 
  7. 'Gaussian Blur' => 44, 'Grafix' => 49, 'Graphics' => 35, 'Hue' => 47, 'Illustrator' => 8, 
  8. 'Image Ready' => 12, 'Javascript' => 47, 'Jpeg' => 15,  'Keyboard' => 18, 'Level' => 28, 
  9. 'Liquify' => 30, 'Listener' => 10, 'Logo' => 12, 'Loops' => 22, 'Macromedia' => 26, 
  10. 'Method' => 28, 'MySQL' => 18, 'Obfuscation' => 13, 'Object' => 39, 'Optimize' => 25, 
  11. 'PDF' => 37, 'PHP' => 44, 'PSD' => 17, 'Photography' => 28, 'Photoshop' => 46, 
  12. 'Revert' => 50, 'Saturation' => 35, 'Save as' => 28, 'Scope' => 11, 'Scripting' => 9, 
  13. 'Security' => 41, 'Sharpen' => 49, 'Switch' => 41, 'Templates' => 11, 'Texture' => 22, 
  14. 'Tool Palette' => 30, 'Variables' => 50);
  15. return $arr;
  16. }
  17. function get_tag_cloud() {
  18. $min_font_size = 12;
  19. $max_font_size = 30;
  20.  
  21.  
  22. $tags = get_tag_data();
  23.  
  24. $minimum_count = min(array_values($tags));
  25. $maximum_count = max(array_values($tags));
  26. $spread = $maximum_count - $minimum_count;
  27.  
  28. if($spread == 0) {
  29. $spread = 1;
  30. }
  31. $cloud_html = '';
  32. $cloud_tags = array();
  33. foreach ($tags as $tag => $count) {
  34. $size = $min_font_size + ($count - $minimum_count) 
  35. * ($max_font_size - $min_font_size) / $spread;
  36. $cloud_tags[] = '<a style="font-size: '. floor($size) . 'px' 
  37. . '" class="tag_cloud" href="http://www.google.com/search?q=' . $tag 
  38. . '" title="'' . $tag . '' returned a count of ' . $count . '">' 
  39. . htmlspecialchars(stripslashes($tag)) . '</a>';
  40. }
  41. $cloud_html = join("n", $cloud_tags) . "n";
  42. return $cloud_html;
  43. }
  44. echo get_tag_cloud();
  45. ?>

a teraz?
-styljola-
A w jaki sposób odpala się go na stronie wstydnis.gif
devnul
RDFM
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.