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

Comments

indytechcook’s picture

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.

indytechcook’s picture

Bump to remind me.

indytechcook’s picture

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.

indytechcook’s picture

Version: 6.x-2.3 » 6.x-3.x-dev
Status: Postponed » Active

Moving to V3

indytechcook’s picture

Title: _taxonomy_menu_term_count($tid) and Views » More Meaningful node count
Version: 6.x-3.x-dev » master

Moving to D7.

indytechcook’s picture

Version: master » 7.x-1.x-dev

Move to D7 version.

dstol’s picture

Status: Active » Closed (duplicate)

Closing as dupe. This is being discussed in #1165386: Node Count for D7 Version (patch included)