public function get_child_ids($parent = 0)
{
// First we get all the categories and store it.
if (empty($this->_all_cats)) {
$this->_ci->db->select('cat_id,cat_parent')->from('categories')->where('cat_display', 'yes');
$query = $this->_ci->db->get();
if ($query->num_rows() == 0) {
return FALSE;
}
$this->_all_cats = $query->result_array();
}
foreach ($this->_all_cats as $row) {
// This assigns all the fields to the array.
foreach ($row as $key => $val) {
$arr[$key] = $val;
}
$menu_array[$row['cat_id']] = $arr;
}
unset($arr);
foreach ($menu_array as $key => $val) {
// Now add any children.
if ($parent == $val['cat_parent'] or $parent == $val['cat_id']) {
$depth = 0;
if (!in_array($val['cat_id'], $this->_cat_ids, TRUE)) {
$this->_cat_ids = array_merge(array($val['cat_id']), $this->_cat_ids);
$this->_child_subtree($key, $menu_array, $depth);
}
}
}
}