2025-06-16 18:28:08 +05:00

21 lines
1.0 KiB
PHP
Executable File

<?php
$smarty->caching = true;
$smarty->cache_lifetime = 86400;
$list=\DB::getAll("SELECT `id`,`title`, `img` FROM `tovar_category` WHERE `category`=? AND `status`=? ORDER BY `sort`, `title`", array($_GET['id'], 1));
$c=count($list);
for ($i=0; $i<$c; $i++){
$list[$i]['submnu']=\DB::getAll("SELECT `id`,`title` FROM `tovar_category` WHERE `category`=? AND `status`=? ORDER BY `sort`, `title`", array($list[$i]['id'], 1));
$list[$i]['more']=(count($list[$i]['submnu'])>10)?1:0;
$list[$i]['submnu'] = array_slice($list[$i]['submnu'], 0, 10);
if (!$list[$i]['img'] || !file_exists($list[$i]['img'])){
$img=\DB::getRow("SELECT `filename`, `content_id` FROM `img` WHERE `content_type`='tovar' AND `content_id` IN (SELECT `id` FROM `tovar` WHERE `category`=" . $list[$i]['id'] . " AND `status`=1 LIMIT 1) LIMIT 1");
if ($img['filename'])$list[$i]['img']='/img/tk-ligat.ru/tovar/' . $img['content_id'] . '/' . $img['filename'] . '.jpg';
unset($img);
}
}
$smarty->assign('list', $list);
?>