add category

This commit is contained in:
Your Name
2021-08-17 00:44:56 +03:00
parent 7ad83909ff
commit 93e8d709ed
4 changed files with 90 additions and 6 deletions

View File

@@ -23,13 +23,19 @@ function bookid_kuri($slug) {
`sub`,
`authorslug`,
`author`,
`priceauthor_id`
`priceauthor_id`,
`price`.`pricepart_id` as `pricepart_id`,
`partname`,
`partalias`
FROM
`price`
LEFT JOIN `pricecategory`
ON price.category_id = pricecategory.category_id
LEFT JOIN `price_authors`
ON `price`.`priceauthor_id` = `price_authors`.`author_id`
LEFT JOIN
`priceparts`
ON `price`.`pricepart_id` = `priceparts`.`pricepart_id`
WHERE
`priceslug` = '$slug'
@@ -114,15 +120,38 @@ function api_books_kuri($filter = 'all', $page = 1){
$sql_books = "
SELECT
*
`price_id`,
`pricename`,
`priceslug`,
price.category_id AS category_id,
`BeginDate`,
`priceanons`,
`priceimg`,
`pricehash`,
`pieces`,
`price`,
`offline_price`,
`sub`,
`authorslug`,
`author`,
`priceauthor_id`,
`price`.`pricepart_id` as `pricepart_id`,
`partname`,
`partalias`
FROM `price`
LEFT JOIN `price_authors` ON `price`.`priceauthor_id` = `price_authors`.`author_id`
LEFT JOIN
`price_authors`
ON `price`.`priceauthor_id` = `price_authors`.`author_id`
LEFT JOIN
`priceparts`
ON `price`.`pricepart_id` = `priceparts`.`pricepart_id`
WHERE $where
ORDER BY `price_id` DESC
LIMIT $limit OFFSET $offset_str";
//echo $sql_books.'<br>';
$books = db_get($sql_books);
if (!isset($books['error'])) {
if ($count > $limit){

View File

@@ -145,4 +145,53 @@ function author_kuri($slug, $page = 1){
}
/**
* книги авторов
*/
function knigi_kuri($slug, $page = 1){
$find_parts_sql = "SELECT * FROM `priceparts` WHERE `partalias` = '$slug' LIMIT 1";
$find_parts = db_get($find_parts_sql);
if (!isset($find_parts['pricepart_id'])){ # 404
echo 'not fount';
exit;
}
$filter = "`price`.`pricepart_id` = ".$find_parts['pricepart_id'];
$books = api_books_kuri($filter, $page);
$baseurl = SITE."knigi/$slug/";
if ($books['pages'] > 1){
$endurl = $baseurl.$books['pages'];
}
if ($page > 1) {
$pagetitle = $find_parts['partname']." - страница $page";
$prevpage = $page - 1 ;
$prevurl = $baseurl.$prevpage;
}
else {
$pagetitle = $find_parts['partname'];
}
if ($page < $books['pages']){
$nextpage = $page+1;
$nexturl = $baseurl.$nextpage;
}
$breadcrumbs['page'] = $pagetitle;
$tempcontent = VIEWPATH.'books.phtml';
include VIEWPATH.'layout.phtml';
}

View File

@@ -9,6 +9,11 @@
<a href="<?=SITE?>author/<?=$book['authorslug']?>"><?=$book['author']?></a>
</p>
<?endif?>
<?if ($book['pricepart_id'] > 0):?>
<p style="text-align: right;">
<a href="<?=SITE?>knigi/<?=$book['partalias']?>"><?=$book['partname']?></a>
</p>
<?endif?>
<p class="pricename"><?=$book['pricename']?></p>
<?=$book['priceanons']?>
<?if ($buy_status):?>

View File

@@ -6,11 +6,12 @@
<a href="<?=$link?>" target="_blank">
<img src="<?=picbook($book, 180, 280)?>" alt="<?=$book['pricename']?>">
</a>
<?if ($book['priceauthor_id'] > 1):?>
<?if ($book['priceauthor_id'] > 0):?>
<p class="book_mini_title">
<a href="<?=SITE?>author/<?=$book['authorslug']?>"><?=$book['author']?></a>
</p>
<?endif?>
<p class="book_mini_title">
<a href="<?=$link?>"><?=$book['pricename']?></a>
</p>