caching = true; $smarty->cache_lifetime = 3600; class modClass{ static function getCategoryInfo($id){ $thisCategory = \DB::getRow("SELECT `id`, `title`, `json`, `txt` FROM `content_category` WHERE `id`=? AND `site`=? AND `status`=1 AND `content_type`='page' LIMIT 1", array($id, $_SERVER['SERVER_NAME']) ); $thisCategory['filename'] = \DB::getValue("SELECT `filename` FROM `img` WHERE `content_type`='cat' AND `content_id`=? AND `site`=? LIMIT 1", array($id, $_SERVER['SERVER_NAME'])); $res['res']=$thisCategory; /* Если что-то не нашли, в шаблон шлем ошибку, в браузер 404 */ if (!$thisCategory['id']) { $res['err']=404; header("HTTP/1.1 404 Not Found"); } return $res; } static function getImg($id){ $img=\DB::getRow("SELECT `filename`, `tip` FROM `img` WHERE `content_type`=? AND `content_id`=? AND `site`=? LIMIT 1", array( 'cat', $_GET['id'], $_SERVER['SERVER_NAME'] )); return '/img/' . $_SERVER['SERVER_NAME'] . '/cat/' . $_GET['id'] . '/' . $img['filename'] . '.' . $img['tip']; } /* ---------------------------------------------------------------------- 05.01.2024 Получаем мета-теги ---------------------------------------------------------------------- */ static function getMeta() { $meta = \DB::getAll("SELECT `txt` FROM `keywords` WHERE `content_type`=? AND `site`=?", array('cat', $_SERVER['SERVER_NAME'])); $count = count($meta); for ($i = 0; $i < $count; $i++) @$txt = @$txt . $meta[$i]['txt'] . ', '; return substr(@$txt, 0, -2); } } $_GET['id'] = ($_GET['id']) ? $_GET['id'] : 0; @mkdir('img/' . $_SESSION['SERVER_NAME'] . '/pages_category', 0700); /* ---------------------------------------------------------------------- 11.08.2023 Получаем информацию о текущей категории ---------------------------------------------------------------------- */ if ($_GET['id'] > 0) { $info=modClass::getCategoryInfo($_GET['id']); if ($info==404) $smarty->assign('err', 404); else $smarty->assign('page_info', $info['res']); } /* ---------------------------------------------------------------------- 11.08.2023 Получаем подкатегории ---------------------------------------------------------------------- */ $smarty->assign('cats', \DB::getAll("SELECT `id`, `title` FROM `content_category` WHERE `category`=? AND `status`=1 AND `site`=? AND `content_type`='page' ORDER BY `title`", array($_GET['id'], $_SERVER['SERVER_NAME']))); /* ---------------------------------------------------------------------- 11.08.2023 Получаем список хлебные крошки ---------------------------------------------------------------------- */ $smarty->assign('Breadcrumb', \core::getBreadcrumb('pages_category', $_GET['id'])); /* ---------------------------------------------------------------------- 11.08.2023 Получаем список страниц в категории ---------------------------------------------------------------------- */ $smarty->assign('list', \core::getContentList(1024, 'page', 3, $_GET['id'])); /* ---------------------------------------------------------------------- 02.04.2023 Получаем самое читабельное ---------------------------------------------------------------------- */ $popular_pages = \DB::getAll("SELECT `id`, `title`, `description`, `alias` FROM `pages` WHERE `status`=1 ORDER BY `see` DESC LIMIT 15"); for ($i = 0; $i < count($popular_pages); $i++) $popular_pages[$i]['filename'] = \DB::getValue("SELECT `filename` FROM `img` WHERE `content_id`=? AND `content_type`='pages_category' LIMIT 1", $popular_pages[$i]['id']); $smarty->assign('popular_pages', $popular_pages); $smarty->assign('keywordsSQL', modClass::getMeta()); ?>