You are here

function shs_term_has_children in Simple hierarchical select 7

Same name and namespace in other branches
  1. 8 shs.module \shs_term_has_children()
  2. 2.0.x shs.module \shs_term_has_children()

Check if a term has any children.

Copied from taxonomy_get_children() but just checks existence instead of loading terms.

1 call to shs_term_has_children()
shs_json_term_get_children in ./shs.module
JSON callback to get the list of children of a term.

File

./shs.module, line 985
Provides an additional widget for term fields to create hierarchical selects.

Code

function shs_term_has_children($tid, $vid) {
  $query = db_select('taxonomy_term_data', 't');
  $query
    ->addExpression(1);
  $query
    ->join('taxonomy_term_hierarchy', 'h', 'h.tid = t.tid');
  $query
    ->condition('h.parent', $tid);
  if ($vid) {
    $query
      ->condition('t.vid', $vid);
  }
  $query
    ->range(0, 1);
  return (bool) $query
    ->execute()
    ->fetchField();
}