Exemple #1
0
 public function setSeoForGroup($page)
 {
     $tpl = DB::select()->from('seo')->where('id', '=', 1)->as_object()->execute()->current();
     $from = array('{{name}}', '{{content}}');
     $text = trim(strip_tags($page->text));
     $to = array($page->name, $text);
     $res = preg_match_all('/{{content:[0-9]*}}/', $tpl->description, $matches);
     if ($res) {
         $matches = array_unique($matches);
         foreach ($matches[0] as $pattern) {
             preg_match('/[0-9]+/', $pattern, $m);
             $from[] = $pattern;
             $to[] = Text::limit_words($text, $m[0]);
         }
     }
     $title = str_replace($from, $to, $tpl->title) . (Arr::get($_GET, 'sort') == 'cost' && Arr::get($_GET, 'type') == 'asc' ? ', От бютжетных к дорогим' : '') . (Arr::get($_GET, 'sort') == 'cost' && Arr::get($_GET, 'type') == 'desc' ? ', От дорогих к бютжетным' : '') . (Arr::get($_GET, 'sort') == 'created_at' && Arr::get($_GET, 'type') == 'desc' ? ', От новых моделей к старым' : '') . (Arr::get($_GET, 'sort') == 'created_at' && Arr::get($_GET, 'type') == 'asc' ? ', От старых моделей к новым' : '') . (Arr::get($_GET, 'sort') == 'name' && Arr::get($_GET, 'type') == 'asc' ? ', По названию от А до Я' : '') . (Arr::get($_GET, 'sort') == 'name' && Arr::get($_GET, 'type') == 'desc' ? ', По названию от Я до А' : '') . (Arr::get($_GET, 'page', 1) > 1 ? ', Страница ' . Arr::get($_GET, 'page', 1) : '');
     $this->_seo['h1'] = str_replace($from, $to, $tpl->h1);
     $this->_seo['title'] = $title;
     $this->_seo['keywords'] = str_replace($from, $to, $tpl->keywords);
     $this->_seo['description'] = str_replace($from, $to, $tpl->description);
     $this->_seo['seo_text'] = $page->text;
     $this->generateParentBreadcrumbs($page->parent_id, 'catalog_tree', 'parent_id', '/catalog/');
     $this->setBreadcrumbs($page->name);
 }