public function get_for_content($content_id, $data_type = 'categories') { if (intval($content_id) == 0) { return false; } if ($data_type == 'categories') { $data_type = 'category'; } if ($data_type == 'tags') { $data_type = 'tag'; } $get_category_items = $this->get_items('group_by=parent_id&rel_type=content&rel_id=' . $content_id); $include_parents = array(); $include_parents_str = ''; if (!empty($get_category_items)) { foreach ($get_category_items as $get_category_item) { if (isset($get_category_item['parent_id'])) { $include_parents[] = $get_category_item['parent_id']; } } } $get_category = $this->get('order_by=position desc&data_type=' . $data_type . '&rel_type=content&rel_id=' . $content_id); if (empty($get_category)) { $get_category = array(); } if (!empty($include_parents)) { $include_parents_str = 'order_by=position desc&data_type=' . $data_type . '&rel_type=content&ids=' . implode(',', $include_parents); $get_category2 = $this->get($include_parents_str); if (!empty($get_category2)) { foreach ($get_category2 as $item) { $get_category[] = $item; } } } // if (is_array($get_category) and !empty($get_category)) { // array_unique($get_category); // } if (empty($get_category)) { return false; } return $get_category; }