public function getTags($fieldName) { $materials = new Model_Material('group'); //получаем ид поля по названию $fields[] = $materials->getField($fieldName); $tags = array(); foreach ($fields as $field) { //получить все значения $result = DB::select('value')->from('group_param_values')->where('pid', '=', $field['id'])->execute(); $vids = $result->as_array(); foreach ($vids as $vid) { $result = DB::select('value')->from($field['type'])->where('id', '=', $vid['value'])->execute(); $values = $result->as_array(); foreach ($values as $value) { $value = explode(',', $value['value']); foreach ($value as $tag) { if ($tag != '') { $tags[trim($tag)] = $materials->str2url($tag); } } } } } ksort($tags); return $tags; }
public function action_tags() { $widgets = array(); $tagName = urldecode($this->request->param('id')); $materials = new Model_Material('groups'); $materialList = $materials->getMidFromTags($tagName); if (!$materialList) { throw new HTTP_Exception_404(); } //Описание ингридиента $tagUrl = $materials->str2url($tagName); $ingridientId = $materials->getMaterialIdByUrl($tagUrl); if ($ingridientId) { $widgets[] = Request::factory('widgets/material/index/' . $ingridientId)->execute(); } $this->styles = array('/css/search.css'); $old_styles = $this->template->styles; array_unique($this->styles); $new_styles = array_merge($this->styles, $old_styles); $this->template->styles = $new_styles; $this->template->title = $tagName . ''; $this->template->page_title = $tagName; $this->template->keywords = $tagName . '' . $tagName; $this->template->description = '' . $tagName; $materialsString = implode('/', $materialList); View::set_global('categoryName', ''); $widgets[] = Request::factory('widgets/catalog/index/' . $materialsString . '/tags')->execute(); $this->template->styles[] = 'css/catalog.css'; $this->template->block_center = $widgets; }