_taxonomy_menu_term_count($tid) and Views

TPerkins - July 28, 2009 - 13:26
Project:Taxonomy Menu
Version:6.x-2.3
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:postponed
Description

Just wanted to say nice module!

One small thing though, that messed me up for my use case. If you have the 'taxonomy_term' view enabled and have modified it through hook_views_pre_view (or another Views hook) or the Views UI, the node count generated from _taxonomy_menu_term_count isn't going to match what is displayed on your screen.

I threw this code together and it works for me. I have the view display set to page, because that seems to be what make sense logically (someone using the taxonomy_term view would be wanting the count to match what is on the resulting views page). I haven't really thought on if/how this should be generalized further.

function _taxonomy_menu_term_count($tid) {
  $view = views_get_view('taxonomy_term');
  if(is_object($view)){
$args = array($tid);
$view->set_arguments($args);
$view->execute_display('page', $args);
return $view->total_rows;
  } else {
return db_result(db_query('SELECT COUNT(n.nid) AS c FROM {term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.status = 1 AND t.tid = %d', $tid));
  }
}

Any thoughts on this?
-Todd

#1

indytechcook - July 29, 2009 - 00:34

This is good. It can added to the code but there would need to be some logic to see if there is a view at the given path.

#2

indytechcook - September 24, 2009 - 12:45

Bump to remind me.

#3

indytechcook - October 31, 2009 - 18:20
Status:active» postponed

I went to see if this was something I could implement today and it needs more flexibility. It really show how incompatible views and a taxonomy menu are. I like the idea and I'm going to use it in V3.

 
 

Drupal is a registered trademark of Dries Buytaert.