{@ if (isset($order_type) && $order_type == 'desc'): $order_type = 'asc'; else: $order_type = 'desc'; endif; $module_info->duration_new = intval($module_info->duration_new ?? 0); if (!$module_info->duration_new): $module_info->duration_new = 12; endif; $category_list = $category_list ?? []; $cate_sub_tabs = ($module_info->sub_category_style ?? '') === 'tabs'; $cate_drop_list = []; $cate_drop_open = 0; $current_key = null; if (!$cate_sub_tabs): foreach ($category_list as $key => $val): if (!$val->depth): $cate_drop_list[$key] = $val; $cate_drop_list[$key]->children = array(); $current_key = $key; elseif ($current_key): $cate_drop_list[$current_key]->children[] = $val; else: continue; endif; if ($current_key && ($category ?? 0) == $val->category_srl): $cate_drop_open = $cate_drop_list[$current_key]->category_srl; endif; endforeach; endif; $cate_children = [0 => []]; foreach ($category_list as $key => $val): $parent_key = isset($category_list[$val->parent_srl]) ? intval($val->parent_srl) : 0; $cate_children[$parent_key][] = $val; endforeach; $cate_list = $cate_children[0]; $cate_path = []; $cate_cursor = intval($category ?? 0); while ($cate_cursor && isset($category_list[$cate_cursor]) && !in_array($cate_cursor, $cate_path)): array_unshift($cate_path, $cate_cursor); $cate_cursor = intval($category_list[$cate_cursor]->parent_srl); endwhile; $cate_sub_rows = []; foreach ($cate_path as $cate_srl): if (!empty($cate_children[$cate_srl])): $cate_sub_rows[$cate_srl] = $cate_children[$cate_srl]; endif; endforeach; }