core/api/modules/tovar_cat/index.php

54 lines
2.0 KiB
PHP
Raw Normal View History

2022-12-11 13:55:49 +05:00
<?php
ini_set('display_errors', 0 );
2023-01-02 21:33:36 +05:00
2022-12-17 18:15:09 +05:00
$smarty -> caching = false;
2023-01-02 21:33:36 +05:00
$smarty -> cache_lifetime = 86400;
2022-12-11 13:55:49 +05:00
2022-12-17 18:15:09 +05:00
$_GET['id'] = ( $_GET['id'] ) ? $_GET['id'] : 0;
$categoryInfo=\DB::getAll("SELECT * FROM `tovar_category` WHERE `id`=?", $_GET['id']);
$smarty->assign('page_info', $categoryInfo);//получаем инфо о категории
2023-01-02 21:33:36 +05:00
$childrenCategory=\DB::getAll("SELECT * FROM `tovar_category` WHERE `status` = 1 AND `category` = ? ORDER BY `title` LIMIT 33", $_GET['id'] );
2022-12-17 18:15:09 +05:00
$smarty->assign('list', $childrenCategory);//получаем дочерние категории
2023-01-02 21:33:36 +05:00
if ($_GET['id']>0)
$childrenTovar=\DB::getAll("SELECT * FROM `tovar` WHERE `category` = ? AND `status`=1", $_GET['id'] );
else
$childrenTovar=\DB::getAll("SELECT * FROM `tovar` WHERE `category`IS NULL AND `status`=1 ORDER BY RANDOM() LIMIT 200" );
for ($i=0; $i<count($childrenTovar); $i++){
$childrenTovar[$i]['cena']=\DB::getValue("SELECT `cena` FROM `tovar_price_history` WHERE `tovar_id`=? ORDER BY `t` DESC LIMIT 1", $childrenTovar[$i]['id']);
$childrenTovar[$i]['img']=\DB::getValue("SELECT `filename` FROM `tovar_img` WHERE `tovar_id`=?", $childrenTovar[$i]['id']);
}
2022-12-17 18:15:09 +05:00
$smarty->assign('list2', $childrenTovar);//получаем дочерние категории
2022-12-11 13:55:49 +05:00
/* ----------------------------------------------------------------------
19.09.2022
Узнаем обложку раздела
---------------------------------------------------------------------- */
2022-12-17 18:15:09 +05:00
$mainImg=\DB::getValue("SELECT `filename` FROM `tovar_category_img` WHERE `tovar_category_id`=?", $_GET['id']);
$smarty->assign('oblozhka', $mainImg);
2023-01-02 21:33:36 +05:00
/* ----------------------------------------------------------------------
28.12.2022
Получаем теги
---------------------------------------------------------------------- */
$meta = \core::getMeta( $_GET['mod'], $_GET['id'] );
$smarty -> assign( 'keywords', $meta['keywords'] );
$smarty -> assign( 'description', $meta['description'] );
2022-12-11 13:55:49 +05:00
?>