I want to change http://api.drupal.org/api/function/taxonomy_term_count_nodes/6 which has 2 queries in a way that i only get listed nodes that have certain CCK field set to for example "sale".

I was trying something with this line

$result = db_query(db_rewrite_sql('SELECT t.tid, COUNT(n.nid) AS c FROM {term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.status = 1 INNER JOIN {content_field_namjena} cfn ON cfn.field_namjena_value GROUP BY t.tid'));

but it doesnt work, and i am cluess how do i set this stuff in {} for CCK tables. please help with some info.

Comments

nevets’s picture

Have you considered using the views module?

Marko B’s picture

hmm no i didnt, was thinking this could be quicker to setup as i already have function that count nodes as this one does.
how could i have this in views? need to have list of children terms of main term, and every child term has to have node count?