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
Comment #1
indytechcook commentedThis 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.
Comment #2
indytechcook commentedBump to remind me.
Comment #3
indytechcook commentedI 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.
Comment #4
indytechcook commentedMoving to V3
Comment #5
indytechcook commentedMoving to D7.
Comment #6
indytechcook commentedMove to D7 version.
Comment #7
dstolClosing as dupe. This is being discussed in #1165386: Node Count for D7 Version (patch included)