core/api/modules/main/p008.yurecnt.ru.php

32 lines
1.8 KiB
PHP

<?php
/* ----------------------------------------------------------------------
01.04.2023
Получаем спиосок категорий страниц
---------------------------------------------------------------------- */
$categories=\DB::getAll("SELECT * FROM `pages_category` ORDER BY `title`");
for ($i=0; $i<count($categories); $i++)$categories[$i]['count']=\DB::getAll("SELECT COUNT(*) FROM `pages` WHERE `category`=? AND `status`=1", $categories[$i]['id'])[0]['COUNT(*)'];
$smarty->assign('categories', $categories);
/* ----------------------------------------------------------------------
02.04.2023
Получаем самое читабельное
---------------------------------------------------------------------- */
$popular_pages=\DB::getAll("SELECT * FROM `pages` WHERE `status`=1 ORDER BY `see` DESC LIMIT 15");
for ($i=0; $i<count($popular_pages); $i++)$popular_pages[$i]['img']=\DB::getValue("SELECT `filename` FROM `pages_img` WHERE `pages_id`=? LIMIT 1", $popular_pages[$i]['id']);
//print_r($popular_pages);
$smarty->assign('popular_pages', $popular_pages);
/* ----------------------------------------------------------------------
02.04.2023
Получаем последние 6 записи
---------------------------------------------------------------------- */
$lost_pages=\DB::getAll("SELECT * FROM `pages` WHERE `status`=1 AND `id`<> 7 ORDER BY `t` DESC LIMIT 6");
for ($i=0; $i<count($lost_pages); $i++){
$lost_pages[$i]['img']=\DB::getValue("SELECT `filename` FROM `pages_img` WHERE `pages_id`=? LIMIT 1", $lost_pages[$i]['id']);
$lost_pages[$i]['count_comments']=\DB::getAll("SELECT COUNT(*) FROM `pages_comments` WHERE `page_id`=? AND `status`=1", $lost_pages[$i]['id'])[0]['COUNT(*)'];
}
//print_r($lost_pages);
$smarty->assign('lost_pages', $lost_pages);
?>