1

Possible Duplicate:
Views and node count for taxonomy terms

I want to count the number of node taxonomy term has in views. I want to display it in content:taxonomy term(exposed). that same as http://www.path.org/blog/ http://wiwisol.com/images/term.png I remove print $exposed; in views--views--xx.tpl.php and add some code. it work http://vnfetp.wiwisol.com/blog but not good.

  <?php //if ($exposed): ?>
<div class="view-filters">    
<?php

$vid = 5;  // number of vocablurary
$total_tid = 0;
$pole = array();
$tid = array();
$terms = taxonomy_get_tree($vid);
foreach ( $terms as $term ) {
    $count = db_query("SELECT COUNT(nid) FROM {taxonomy_index} WHERE tid = :aid", array(':aid' => $term->tid) )->fetchField();
    $pole[]=l($term->name."(".$count.")", 'taxonomy/term/'.$term->tid.'');
    $tid[] = $term->tid;
    $total_tid++;
}
$item = 0;
$selected = "selected";

if(empty($_GET['tid']))
    $tid1 = "All";
else
    $tid1 = $_GET['tid'];
?>
<form class="ctools-auto-submit-full-form" action="fetp/blog" method="get" id="views-exposed-form-blog-block" accept-charset="UTF-8"><div><div class="views-exposed-form">

CONTINUE CODE:

<div class="views-exposed-widgets clearfix">
      <div id="edit-tid-wrapper" class="views-exposed-widget views-widget-filter-tid">
              <label for="edit-tid">
        Categories          </label>
                    <div class="views-widget">
      <div class="form-item form-type-select form-item-tid">

CONTINUE CODE:

 <select id="edit-tid" name="tid" class="form-select"><option value="All" selected="<?php echo $selected;;?>">- Any -</option>

CONTINUE CODE:

<?php 

foreach ($pole as $list) { if($item < $total_tid) { if($tid[$item]== $tid1) { echo ''.$list.''; } else { $selected = ""; echo ''.$list.''; } } else { echo '- Any -'; $item = 0; }
$item++; } ?>

CONTINUE CODE:

</select>

CONTINUE CODE:

    </div>
  </div>
                <div class="views-exposed-widget views-submit-button">
  <input class="ctools-use-ajax ctools-auto-submit-click js-hide form-submit" type="submit" id="edit-submit-blog" name="" value="Search" />    </div>
  </div>

  <?php //dsm($exposed); //print $exposed; //var_dump($exposed); ?>
</div>

It work, but not fine when more than two exposed filter. How to count the number of node a Taxonomy term has? help me please, Thank you very much.

2

Browse other questions tagged or ask your own question.