add authors page

This commit is contained in:
Your Name
2021-08-17 00:02:41 +03:00
parent 84d69e8385
commit 7ad83909ff
4 changed files with 130 additions and 15 deletions

View File

@@ -7,11 +7,30 @@ function bookid_kuri($slug) {
$query = " $query = "
SELECT SELECT
`price_id`, `pricename`, `categoryname`, `priceslug`, `categoryslug`, price.category_id AS category_id, `BeginDate`, `priceanons`, `priceimg`, `pricehash`, `pieces`, `price`, `offline_price`, `sub` `price_id`,
`pricename`,
`categoryname`,
`priceslug`,
`categoryslug`,
price.category_id AS category_id,
`BeginDate`,
`priceanons`,
`priceimg`,
`pricehash`,
`pieces`,
`price`,
`offline_price`,
`sub`,
`authorslug`,
`author`,
`priceauthor_id`
FROM FROM
`price` `price`
LEFT JOIN `pricecategory` LEFT JOIN `pricecategory`
ON price.category_id = pricecategory.category_id ON price.category_id = pricecategory.category_id
LEFT JOIN `price_authors`
ON `price`.`priceauthor_id` = `price_authors`.`author_id`
WHERE WHERE
`priceslug` = '$slug' `priceslug` = '$slug'
LIMIT 1 LIMIT 1
@@ -43,8 +62,9 @@ function bookid_kuri($slug) {
/** /**
* вернуть товары магазина (все или по фильтру) * вернуть товары магазина (все или по фильтру)
*
*/ */
function api_books_kuri($category = 'knigi', $filter = 'all', $page = 1){ function api_books_kuri($filter = 'all', $page = 1){
$limit = 24; $limit = 24;
@@ -56,12 +76,19 @@ function api_books_kuri($category = 'knigi', $filter = 'all', $page = 1){
$offset_str = 0; $offset_str = 0;
} }
if ($category == 'all'){
if ($filter == 'all'){
$where = ''; $where = '';
} }
else { else {
$where = "$filter ";
}
$category_sql = "SELECT `category_id` FROM `pricecategory` WHERE `categoryslug` = '$category' LIMIT 1";
//`categoryslug` = '$category'
/* $category_sql = "SELECT `category_id` FROM `pricecategory` WHERE $filter LIMIT 1";
$category = db_get($category_sql); $category = db_get($category_sql);
@@ -70,9 +97,14 @@ function api_books_kuri($category = 'knigi', $filter = 'all', $page = 1){
$where = "WHERE `category_id` = $category_id"; $where = "WHERE `category_id` = $category_id";
} }
} } */
$db_count = db_get("SELECT COUNT(price_id) AS count FROM `price` $where LIMIT 1;"); if ($where !== '')
$where .= "AND `active` = 1 ";
else
$where .= "`active` = 1 ";
$db_count = db_get("SELECT COUNT(price_id) AS count FROM `price` WHERE $where LIMIT 1;");
if (isset($db_count['error'])) if (isset($db_count['error']))
return False; return False;
@@ -80,8 +112,15 @@ function api_books_kuri($category = 'knigi', $filter = 'all', $page = 1){
if (isset($db_count['count'])) if (isset($db_count['count']))
$count = $db_count['count']; $count = $db_count['count'];
$sql_books = "SELECT * FROM `price` $where AND `active` = 1 ORDER BY `price_id` DESC LIMIT $limit OFFSET $offset_str"; $sql_books = "
SELECT
*
FROM `price`
LEFT JOIN `price_authors` ON `price`.`priceauthor_id` = `price_authors`.`author_id`
WHERE $where
ORDER BY `price_id` DESC
LIMIT $limit OFFSET $offset_str";
//echo $sql_books.'<br>';
$books = db_get($sql_books); $books = db_get($sql_books);
if (!isset($books['error'])) { if (!isset($books['error'])) {

View File

@@ -36,22 +36,36 @@ function product_kuri($slug){
} }
/**
* категории товаров
*/
function category_kuri($category = '', $filter = 'all', $page = 1){ function category_kuri($category = '', $filter = 'all', $page = 1){
if ($category == ''){ if ($category == ''){
if (SUBSTATUS == 1){ if (SUBSTATUS == 1){ // категория по умолчанию
$category = 'gazeta'; $category = 'gazeta';
$filter = "category_id = 1";
} }
else { else {
$category = 'knigi'; $category = 'knigi';
$filter = "category_id = 3";
} }
} }
elseif ($category == 'gazeta') {
$filter = "category_id = 1";
}
elseif ($category == 'knigi') {
$filter = "category_id = 3";
}
$cats = api_cats(); $cats = api_cats();
$books = api_books_kuri($category, $filter, $page);
$books = api_books_kuri($filter, $page);
$baseurl = SITE."category/$category/$filter/"; $baseurl = SITE."category/$category/$filter/";
@@ -81,4 +95,54 @@ function category_kuri($category = '', $filter = 'all', $page = 1){
$tempcontent = VIEWPATH.'books.phtml'; $tempcontent = VIEWPATH.'books.phtml';
include VIEWPATH.'layout.phtml'; include VIEWPATH.'layout.phtml';
}
/**
* книги авторов
*/
function author_kuri($slug, $page = 1){
$find_author_sql = "SELECT * FROM `price_authors` WHERE `authorslug` = '$slug' LIMIT 1";
$find_author = db_get($find_author_sql);
if (!isset($find_author['author_id'])){ # 404
echo 'not fount';
exit;
}
$filter = "`priceauthor_id` = ".$find_author['author_id'];
$books = api_books_kuri($filter, $page);
$baseurl = SITE."author/$slug/";
if ($books['pages'] > 1){
$endurl = $baseurl.$books['pages'];
}
if ($page > 1) {
$pagetitle = $find_author['author'].". Книги - страница $page";
$prevpage = $page - 1 ;
$prevurl = $baseurl.$prevpage;
}
else {
$pagetitle = $find_author['author'].". Книги";
}
if ($page < $books['pages']){
$nextpage = $page+1;
$nexturl = $baseurl.$nextpage;
}
$breadcrumbs['page'] = $pagetitle;
$tempcontent = VIEWPATH.'books.phtml';
include VIEWPATH.'layout.phtml';
} }

View File

@@ -4,6 +4,11 @@
</div> </div>
<div id="priceanons"> <div id="priceanons">
<p class="artikul"><small>Артикул <?=$book['price_id']?></small></p> <p class="artikul"><small>Артикул <?=$book['price_id']?></small></p>
<?if ($book['priceauthor_id'] > 1):?>
<p class="pricename">
<a href="<?=SITE?>author/<?=$book['authorslug']?>"><?=$book['author']?></a>
</p>
<?endif?>
<p class="pricename"><?=$book['pricename']?></p> <p class="pricename"><?=$book['pricename']?></p>
<?=$book['priceanons']?> <?=$book['priceanons']?>
<?if ($buy_status):?> <?if ($buy_status):?>

View File

@@ -6,9 +6,16 @@
<a href="<?=$link?>" target="_blank"> <a href="<?=$link?>" target="_blank">
<img src="<?=picbook($book, 180, 280)?>" alt="<?=$book['pricename']?>"> <img src="<?=picbook($book, 180, 280)?>" alt="<?=$book['pricename']?>">
</a> </a>
<p class="book_mini_title"><?=$book['pricename']?></p> <?if ($book['priceauthor_id'] > 1):?>
<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>
<p class="price"> <p class="price">
<a href="<?=$link?>" target="_blank">Читать</a> <a href="<?=$link?>">Читать</a>
</p> </p>
</a> </a>