Drupal: .htaccess Access Deny
August 21, 2014 – 7:59 am | No Comment

In this article I will tell how to forbid access to certain resources for some clients. The instructions will include descriptions of different directives.

Read the full story »
CSS Templates

Contain reviews and news about CSS Templates.

Freebies

Contain freebies such as icons, graphics, headers and images for your websites.

Fun Stuff

Contains other fun stuff for entertainment or interesting site showcase.

How-To

Contain technical elaborations on some specific workarounds or common tweak.

Joomla Templates

Contains reviews and news about Joomla templates.

Home » How-To

Drupal: How to Show Tag Cloud in a Block

Submitted by on December 24, 2010 – 9:12 amNo Comment

And now I would tell you how to show tag cloud in a block.

Solutions

  • Use a snippet to show tag cloud for a specified vocabulary
  • Use tagadelic module

Snippet to show tag cloud for a specified vocabulary

Shows tag cloud for a specified vocabulary – $voc variable.

<?php
$max_fontsize = 150; // Размер шрифта для тэга с максимальным весом
$min_fontsize = 90; // Размер шрифта для тэга с минимальным весом
$metrics = ‘%'; // в чем измеряется размер px,pt,em,%
$voc = 3; // vid словаря
// получим максимальны и минимальный вес терминов в словаре
$result = db_query(db_rewrite_sql(“SELECT max(cnt) AS maxcnt,min(cnt) AS mincnt
FROM {term_data} td  INNER JOIN
(SELECT tn.tid,COUNT(tn.nid) as cnt  FROM {term_node} tn
INNER JOIN {node} n ON n.nid=tn.nid GROUP BY tn.tid) n
ON n.tid=td.tid AND td.vid=%d”),$voc);
$term = db_fetch_object($result);
$min_weight = $term->mincnt;
$max_weight = $term->maxcnt;
// вычислим коэффициент для размера шрифта
if ($min_weight == $max_weight ) {
$font_metric_koof = 0;
}
else {
$font_metric_koof = ($max_fontsize – $min_fontsize) / ($max_weight – $min_weight);
}
$result = db_query(db_rewrite_sql(“SELECT td.tid,td.name,n.cnt
FROM {term_data} td  INNER JOIN
(SELECT tn.tid,COUNT(tn.nid) as cnt  FROM {term_node} tn
INNER JOIN {node} n ON n.nid=tn.nid GROUP BY tn.tid) n
ON n.tid=td.tid AND td.vid=%d ORDER BY td.name”),$voc);
$tags = ”;
while($term = db_fetch_object($result)) {
$size = $min_fontsize + ($term->cnt – $min_weight) * $font_metric_koof;
$style = ‘font-size: ‘.$size.$metrics.';';
$tags .= l($term->name,’taxonomy/term/’.$term->tid,
array(‘attributes’ => array(‘style’ => $style,’class’ => ‘tags-voc-‘.$voc))).’ ‘;
}
if (!empty($tags)) {
print ‘<tags class=”voc-‘.$voc.'”>’.$tags.'</tags>';
}
?>

Themization
For themization of a.tags-voc-vocabulary-number terms, you can use tags.voc-vocabulary-number stylization.

tagadelic module

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.