29 lines
862 B
PHP
29 lines
862 B
PHP
<?php
|
|
class ControllerServiceMenu extends Controller {
|
|
public function index() {
|
|
$this->load->model('service/category');
|
|
|
|
$data['categories'] = $this->getCategories();
|
|
|
|
return $this->load->view('service/menu', $data);
|
|
}
|
|
|
|
private function getCategories($parent_id = 0, $path = '') {
|
|
$category_data = array();
|
|
$categories = $this->model_service_category->getCategories($parent_id);
|
|
|
|
foreach ($categories as $category) {
|
|
$category_path = $path ? $path . '_' . $category['service_category_id'] : $category['service_category_id'];
|
|
|
|
$category_data[] = array(
|
|
'name' => $category['name'],
|
|
'href' => $this->url->link('service/category', 'service_category_id=' . $category_path)
|
|
);
|
|
|
|
$category_data = array_merge($category_data, $this->getCategories($category['service_category_id'], $category_path));
|
|
}
|
|
|
|
return $category_data;
|
|
}
|
|
}
|