hello!

when i enable "Display the node count" and/or "Require associated node" in a exposed taxonomy id filter in a view, i'm getting this error:

user warning: in C:\Program Files (x86)\EasyPHP5\www\mysite\sites\all\modules\hierarchical_select\modules\hs_taxonomy_views.module on line 529

thank you!

Comments

wim leers’s picture

Assigned: brunorios1 » Unassigned
Priority: Critical » Normal
Status: Active » Closed (cannot reproduce)
Issue tags: -view, -user warning, -exposed

That's not very helpful. I'd need more details.

Also, please don't use the tags system like that.

charlysole’s picture

Exactly the same problem here...

I have Taxonomy term filter exposed using HS. (Taxonomy Term modiffied default view)
If you try to use the options Display the node count or Require associated node my drupal returns

user warning: 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 ') count_alias' at line 1 query: SELECT COUNT(*) FROM () count_alias in /usr/home/SITE.com/web/sites/all/modules/hierarchical_select/modules/hs_taxonomy_views.module on line 535.

Four times

Kook’s picture

Old question, but as I was able to replicate and fix this may help someone out.

Find the following in the /modules/hierachical_select/modules/hs_taxonomy_views.module file;

$count_query = $temp_view->build_info['count_query'];
$args        = $temp_view->build_info['query_args'];

Replace with the following;

//$count_query = $temp_view->build_info['count_query'];
    //$args        = $temp_view->build_info['query_args'];
    $count_query = !empty($temp_view->build_info['count_query']) ? $temp_view->build_info['count_query'] : $temp_view->query->count_query;
    $args = !empty($temp_view->build_info['query_args']) ? $temp_view->build_info['query_args'] : $temp_view->query->query_args;

and then just below it (to make sure it doesn't return the error);

$count_query = str_replace("SELECT node.nid AS nid", "SELECT DISTINCT(node.nid) AS nid", $count_query);

Replace with

        if(strlen($count_query) > 0){
                $count_query = str_replace("SELECT node.nid AS nid", "SELECT DISTINCT(node.nid) AS nid", $count_query);
        }else{
                $count_query = "SELECT DISTINCT(t.nid) FROM {term_node} t INNER JOIN {node} n ON t.nid = n.nid WHERE n.status = 1 and t.tid = '". $item ."'";
        }

Reasoning being I would prefer a slightly inaccurate count over a crash, just in case for some reason that $count_query string is empty, which is what caused the original issue.