core/api/modules/cat/index.php

58 lines
3.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
ini_set('display_errors', 0 );
$_GET['id']=($_GET['id'])?$_GET['id']:0;
@mkdir('img/' . $_SESSION['SERVER_NAME'] . '/pages_category', 0700);
/* ----------------------------------------------------------------------
11.08.2023
Получаем информацию о текущей категории
---------------------------------------------------------------------- */
if ( $_GET['id']>0 ){
$thisCategory=\DB::getRow( "SELECT `id`, `title`, `subtitle`, `description`, `keywords` FROM `pages_category` WHERE id=? LIMIT 1", $_GET['id'] );
$thisCategory['filename']=\DB::getValue( "SELECT `filename` FROM `img` WHERE `content_type`='pages_category' AND `content_id`=? LIMIT 1", $_GET['id'] );
$smarty -> assign( 'page_info',$thisCategory);
}
/* ----------------------------------------------------------------------
11.08.2023
Получаем подкатегории
---------------------------------------------------------------------- */
$cats=\DB::getAll("SELECT `id`, `title` FROM `pages_category` WHERE `category`=? AND `status`=1 ORDER BY `title`", $_GET['id']);
$smarty -> assign( 'cats', $cats );
/* ----------------------------------------------------------------------
11.08.2023
Получаем список хлебные крошки
---------------------------------------------------------------------- */
$b=\core::getBreadcrumb('pages_category', $_GET['id']);
$smarty -> assign( 'Breadcrumb', $b );
/* ----------------------------------------------------------------------
11.08.2023
Получаем список страниц в категории
---------------------------------------------------------------------- */
$list = \DB::getAll( "SELECT `id`, `title`, `alias`, `t`, `reyt`, `see`,`description` FROM `pages` WHERE `category`=? ORDER BY `t` DESC", $_GET['id'] );
for ( $i=0; $i < count( $list ); $i++ ) {
$list[$i]['filename'] = \DB::getValue( "SELECT `filename` FROM `img` WHERE `content_type`='pages' AND `content_id`=? LIMIT 1", $list[$i]['id'] );
$list[$i]['link']=($list[$i]['alias'])?'/'.$list[$i]['alias'] . '.html':'/page/'.$list[$i]['id'];
}
//print_r($list);
$smarty -> assign( 'list', $list );
/* ----------------------------------------------------------------------
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 `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]['img']=\DB::getValue("SELECT `filename` FROM `pages_img` WHERE `pages_id`=? LIMIT 1", $popular_pages[$i]['id']);
$smarty->assign('popular_pages', $popular_pages);
?>