I am calling the following function inside a template for a custom content type, but my senior developer suggested that calling a function inside a template file is not Drupal standard.
function some_function($AA_tid = 0) {
$dis_pt = db_select('some_tble', 'v')
->fields('v', array('title'))
->condition('some_fld', $AA_tid)
->distinct();
$dis_pt->join('another_tble', 'ss', 'v.title = ss.type');
$dis_pt->fields('ss', array('name'));
$result = $dis_pt->execute()->fetchAll();
return $result;
}
Should I call the function which will query the database from a content type template? Generally speaking, is it better to avoid such code in a template file?
Edit: function call is present inside the template & its definition is available in some module file.