Hi,
I am using the following code in my theme
$term = taxonomy_Get_term($termid);
$tree = taxonomy_get_tree($term->vid, $term->tid);
$descendant_tids = array_merge(array($term->tid), array_map('_taxonomy_get_tid_from_term', $tree));
$sql = "SELECT n.title, n.nid FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN (". implode(',', $descendant_tids) .") AND n.status=1 ORDER BY n.created DESC";
$result = db_fetch_object(db_query_range(db_rewrite_sql($sql), 0, $count));
print "<div class='text'><h4>".$term->name."</h4>";
if ($result) {
print "<a href='".url("node/".$result->nid)."'>".$result->title."</a>";If I enable taxonomy access control with this code, then my site stops displaying results for this code. I get the following errors in my log
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DISTINCT(n.nid) FROM node n INNER JOIN term_node tn ON n.nid = tn.nid INNER JOI' at line 1 query: SELECT n.title, DISTINCT(n.nid) FROM node n INNER JOIN term_node tn ON n.nid = tn.nid INNER JOIN node_access na ON na.nid = n.nid WHERE (na.grant_view >= 1 AND ((na.gid = 0 AND na.realm = 'all'))) AND ( tn.tid IN (8,9,11,12,13,39) AND n.status=1 ) ORDER BY n.created DESC LIMIT 0, 1 in /home/website/public_html/includes/database.mysql.inc on line 172
does someone know how I can fix this?
Comments
Comment #1
gpk commentedI'm not sure that TAC is to blame since the implementation of hook_db_rewrite_sql() in the TAC module does not rewrite node queries (see http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/taxonomy_ac...).
Actually I can't see what the problem is with the query in any case ..?
Comment #2
xjmThis is the same SQL error as in #187171: sql error after installing tac; marking as duplicate.