В пагинации на страницах отображаются дубли страниц....( 1 1 2 3).
Помогите пожалуйста.
pagination.php
<?php
class Pagination {
public $total = 0;
public $page = 1;
public $limit = 9999;
public $num_links = 3;
public $url = '';
public $text_first = '1';
public $text_last = '>|';
public $text_next = '>';
public $text_prev = '<';
public function render() {
/* echo '<pre>';
var_dump(isset($_GET['route']));
echo '</pre>';
die();*/
if(isset($_GET['route'])){
$takeArea = explode('/',$_GET['route']);
switch ($takeArea[0]) {
case 'catalog':
case 'common':
if ($this->page < 1) {
$page = 1;
} else {
$page = $this->page;
}
if (!(int)$this->limit) {
$limit = 10;
} else {
$limit = $this->limit;
}
$num_links = $this->num_links;
$num_pages = ceil($total / $limit);
$this->url = str_replace('%7Bpage%7D', '{page}', $this->url);
$output = '<ul class="pagination">';
if ($page > 1) {
$tmp_url = str_replace('&', '&', $this->url);
$output .= '<li><a href="' . str_replace('&', '&', rtrim( str_replace('page={page}', '', $tmp_url), '?&')) . '">' . $this->text_first . '</a></li>';
if ($page == 2){
$output .= '<li><a href="' . str_replace('&', '&', rtrim( str_replace('page={page}', '', $tmp_url), '?&')) . '">' . $this->text_prev . '</a></li>';
}else{
$output .= '<li><a href="' . str_replace('{page}', $page - 1, $this->url) . '">' . $this->text_prev . '</a></li>';
}
}
if ($num_pages > 1) {
if ($num_pages <= $num_links) {
$start = 1;
$end = $num_pages;
} else {
$start = $page - floor($num_links / 2);
$end = $page + floor($num_links / 2);
if ($start < 1) {
$end += abs($start) + 1;
$start = 1;
}
if ($end > $num_pages) {
$start -= ($end - $num_pages);
$end = $num_pages;
}
}
for ($i = $start; $i <= $end; $i++) {
if ($page == $i) {
$output .= '<li class="active"><span>' . $i . '</span></li>';
} else {
if ($i == 1){
$output .= '<li><a href="' . str_replace('&', '&', rtrim( str_replace('page={page}', '', $tmp_url), '?&')) . '">' . $i . '</a></li>';
}else{
$output .= '<li><a href="' . str_replace('{page}', $i, $this->url) . '">' . $i . '</a></li>';
}
}
}
}
if ($page < $num_pages) {
$output .= '<li><a href="' . str_replace('{page}', $page + 1, $this->url) . '">' . $this->text_next . '</a></li>';
$output .= '<li><a href="' . str_replace('{page}', $num_pages, $this->url) . '">' . $this->text_last . '</a></li>';
}
$output .= '</ul>';
if ($num_pages > 1) {
return $output;
} else {
return '';
}
break;
default:
$total = $this->total;
if ($this->page < 1) {
$page = 1;
} else {
$page = $this->page;
}
if (!(int)$this->limit) {
$limit = 10;
} else {
$limit = $this->limit;
}
$num_links = $this->num_links;
$num_pages = ceil($total / $limit);
$this->url = str_replace('%7Bpage%7D', '{page}', $this->url);
$output = '<div class="pagination_wrap f_right">';
if ($page > 1 && $page >= 3 && $num_pages > 3) {
$output .= '<a href="' . str_replace('{page}', 1, $this->url) . '">' . $this->text_first . '</a>';
if($page >= 3){
$output .= '<span href="#" class="more">...</span>';
}
}
if ($num_pages > 1) {
if ($num_pages <= $num_links) {
$start = 1;
$end = $num_pages;
} else {
$start = $page - floor($num_links / 2);
$end = $page + floor($num_links / 2);
if ($start < 1) {
$end += abs($start) + 1;
$start = 1;
}
if ($end > $num_pages) {
$start -= ($end - $num_pages);
$end = $num_pages;
}
}
for ($i = $start; $i <= $end; $i++) {
if ($page == $i) {
$output .= '<a href="' . str_replace('{page}', $i, $this->url) . '" class="active">' . $i . '</a>';
$output .= '<a href="' . str_replace('{page}', $i + 1, $this->url) . '" class="smore-product" style="display:none;"></a>';
} else {
$output .= '<a href="' . str_replace('{page}', $i, $this->url) . '">' . $i . '</a>';
}
}
}
if ($page > 3 && $page < $num_pages && ($page < $num_pages-1 || $page < $num_pages-2) || $page < $num_pages-2) {
$output .= '<span href="#" class="more">...</span>';
if($num_pages > $num_pages-3){
$output .= '<a href="' . str_replace('{page}', $num_pages, $this->url) . '">' . $num_pages . '</a>';
}
}
$output .= '</div>';
if ($num_pages > 1) {
return $output;
} else {
return '';
}
break;
}
}else{
$total = $this->total;
if ($this->page < 1) {
$page = 1;
} else {
$page = $this->page;
}
if (!(int)$this->limit) {
$limit = 10;
} else {
$limit = $this->limit;
}
$num_links = $this->num_links;
$num_pages = ceil($total / $limit);
$this->url = str_replace('%7Bpage%7D', '{page}', $this->url);
$output = '<div class="pagination_wrap f_right">';
if ($page > 1 && ($page != 2 && $page != 3) || $page == 3) {
$output .= '<a href="' . str_replace('{page}', 1, $this->url) . '">' . $this->text_first . '</a>';
if($page > 3){
$output .= '<span href="#" class="more">...</span>';
}
}
if ($num_pages > 1) {
if ($num_pages <= $num_links) {
$start = 1;
$end = $num_pages;
} else {
$start = $page - floor($num_links / 2);
$end = $page + floor($num_links / 2);
if ($start < 1) {
$end += abs($start) + 1;
$start = 1;
}
if ($end > $num_pages) {
$start -= ($end - $num_pages);
$end = $num_pages;
}
}
for ($i = $start; $i <= $end; $i++) {
if ($page == $i) {
$output .= '<a href="' . str_replace('{page}', $i, $this->url) . '" class="active">' . $i . '</a>';
$output .= '<a href="' . str_replace('{page}', $i + 1, $this->url) . '" class="smore-product" style="display:none;"></a>';
} else {
$output .= '<a href="' . str_replace('{page}', $i, $this->url) . '">' . $i . '</a>';
}
}
}
if ($page > 3 && $page < $num_pages && ($page < $num_pages-1 || $page < $num_pages-2) || $page < $num_pages-2) {
$output .= '<span href="#" class="more">...</span>';
if($num_pages > $num_pages-3){
$output .= '<a href="' . str_replace('{page}', $num_pages, $this->url) . '">' . $num_pages . '</a>';
}
}
$output .= '</div>';
if ($num_pages > 1) {
return $output;
} else {
return '';
}
}
}
}
category.tpl
<?php echo $header; ?>
<main>
<section class="">
<div class="container">
<div class="row">
<div class="col-md-12 col-lg-12">
<div class="breadcrumbs">
<?php
$count_bread = count($breadcrumbs);
$count = 1;
foreach ($breadcrumbs as $breadcrumb) { ?>
<?php if ($count != $count_bread) {
$count++; ?>
<a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a> /
<?php } else { ?>
<span><?php echo $breadcrumb['text']; ?></span>
<?php } ?>
<?php } ?>
<?php if (isset($breadcrumbs[1]['catIdParent'])) {
$parentCat = $breadcrumbs[1]['catIdParent'];
$childCat = $breadcrumbs[1]['catIdChild'];
} else {
$parentCat = '';
$childCat = '';
}
?>
<input type="hidden" id="parentCat" value="<?php echo $parentCat; ?>">
<input type="hidden" id="childCat" value="<?php echo $childCat; ?>">
</div>
</div>
</div>
<?php if (!empty($categories)){ ?>
<div class="row">
<div class="col-md-12 col-lg-12">
<div class="category_page">
<h3><?php echo $heading_title; ?></h3>
<?php if ($categories) { ?>
<div class="wrap_subcategories">
<div class="col_links">
<?php $colonProd = ceil(count($categories) / 3); ?>
<?php
$count = 0;
foreach ($categories as $category) { ?>
<?php if (($count % $colonProd) == 0 && $count != 0){ ?>
</div>
<div class="col_links">
<?php } ?>
<a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
<?php $count++;
} ?>
</div>
<div class="clear"></div>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
</section>
<?php } ?>
<?php if (empty($categories)) { ?>
</div>
<div class="container subcategory">
<div class="row">
<div class="col-sm-12 col-md-3 col-lg-3">
<div class="filter_button">
<div>Показать фильтр</div>
<span><i class="fa fa-chevron-down"></i>
</span>
<div class="clear"></div>
</div>
<aside class="left_col">
<?= $column_left; ?>
<div class="left_section">
<div class="section_title">Торговая марка</div>
<ul class="manufacturer_filter">
<?php
if (!empty($data_manuf)) { ?>
<?php foreach ($data_manuf as $key => $value) {
?>
<li data-href='<?= $url; ?>'>
<label <?= (!empty($count_manufacturer) && array_key_exists($value['manufacturer_id'], $count_manufacturer)) ? '' : 'class="disabled"'; ?>>
<input <?= (!empty($count_manufacturer) && array_key_exists($value['manufacturer_id'], $count_manufacturer)) ? '' : 'disabled="disabled"'; ?> value="<?= $value['manufacturer_id']; ?>"
type="checkbox" <?= (array_key_exists($value['manufacturer_id'], $count_manufacturer) && $value['checked']) ? $value['checked'] : ''; ?>>
<span></span><?= $value['name']; ?>
(<?= (!empty($count_manufacturer) && array_key_exists($value['manufacturer_id'], $count_manufacturer)) ? $count_manufacturer[$value['manufacturer_id']]['count'] : 0; ?>)</label>
</li>
<?php }
} ?>
</ul>
</div>
<div class="left_section">
<div class="section_title">Цена</div>
<div class="range_wrap">
<div id="price-range-details" class="price-filter">
<input type="text" id="price-range-low" value="" class="separator">
<span class="range_text">-</span>
<input type="text" id="price-range-high" value="">
<span class="range_text" style="margin-right:0;">грн.</span>
<div class="clear"></div>
</div>
<div id="price-range" class="price-filter">
</div>
<div class="price-filter">
<input type="hidden" id="needShow" value="<?= $products[0]['price'] ?>">
<script>
$(document).ready(function () {
var minprice = $('#needShow').val();
var isShown = minprice.split(' ');
var yesShow = isShown[0] * 1;
if (yesShow > 0) {
$('#price-range').noUiSlider({
range: [<?= floor($start_price[0]['minprice']) != ceil($start_price[0]['maxprice']) ? floor($start_price[0]['minprice']) : 0; ?>, <?=ceil($start_price[0]['maxprice']) ?>],
start: [<?=(isset($min_price_sart)) ? floor($min_price_sart) : floor($start_price[0]['minprice']);?>, <?=(isset($max_price_sart)) ? ceil($max_price_sart) : ceil($min_max_price[0]['maxprice']) ?>],
handles: 2,
connect: true,
step: 1,
serialization: {
to: [$('#price-range-low'), $('#price-range-high')],
resolution: 1
}
});
}
});
</script>
</div>
</div>
</div>
</aside>
</div>
<?php
/*echo "<pre>";
print_r($products);
<!-- print_r($sorts); -->
echo "</pre>";*/
?>
<?php if ($products) { ?>
<div class="col-sm-12 col-md-9 col-lg-9">
<h2 class="title_page"><?php echo $heading_title; ?></h2>
<div class="filter_select">
<div class="span_sort f_left">Отсортировано:</div>
<select>
<?php foreach ($sorts as $sorts) { ?>
<?php if ($sorts['value'] == $sort . '-' . $order) { ?>
<option value="<?php echo $sorts['href']; ?>"
selected="selected"><?php echo $sorts['text']; ?></option>
<?php } else { ?>
<option value="<?php echo $sorts['href']; ?>"><?php echo $sorts['text']; ?></option>
<?php } ?>
<?php } ?>
</select>
<div class="clear"></div>
<span id="filterReturnZero" style="display: none;"><span class="no-item">Товаров с указанными характеристиками нет, повторите, пожалуйста, запрос с другими параметрами.</span></span>
</div>
<div class="row subcategory_list">
<?php foreach ($products as $product) { ?>
<?php
/*echo '<pre>';
print_r($product);
echo '</pre>';
die();*/
?>
<?php
$akciya = '';
if (!isset($akciya)) {
$class = 'sale';
} elseif ($product['popular_product'] == 1) {
$class = 'hit';
} elseif ($product['product_innovation'] == 1) {
$class = 'new';
} else {
$class = '';
}
if ($product['drawing_product'] == 1) {
$class .= ' draw';
}
?>
<div class="col-sm-6 col-md-4 col-lg-4 items_prod">
<div class="item <?= $class; ?>">
<?php if (in_array($product['product_id'], $wishlist)) {
$class_active = 'active';
$wish = 'onclick="wishlist.remove(' . $product['product_id'] . ', this);" ontouchend="wishlist.add(' . $product['product_id'] . ', this);"';
} else {
$class_active = '';
$wish = 'onclick="wishlist.add(' . $product['product_id'] . ', this);" ontouchend="wishlist.add(' . $product['product_id'] . ', this);"';
} ?>
<a class="liked <?= $class_active; ?>" <?= $wish; ?>><i class="fa fa-heart"></i></a>
<a href="<?php echo $product['href']; ?>">
<img src="<?php echo $product['thumb']; ?>"
alt="<?php echo $product['name']; ?>"
title="<?php echo $product['name']; ?>">
<div class="description_prod">
<div class="name"><?php echo $product['name']; ?></div>
<?php if (!$product['special']) { ?>
<div class="price"><?php echo $product['price']; ?>
<span>/ 1 <?= $product['weight_goods'] == 0 ? 'шт' : 'кг'; ?></span>
</div>
<?php } else { ?>
<div class="price"><?php echo $product['special']; ?> <span
class="price-old"> <?php echo $product['price']; ?></span>
<span>/ 1 <?= $product['weight_goods'] == 0 ? 'шт' : 'кг'; ?></span>
</div>
<?php } ?>
<div class="opt_price">
<span><?= $product['disc_price']?></span>
<span>/ от <?= $product['disc_quantity']?>-х единиц</span>
</div>
</div>
</a>
<div class="qtywrapper">
<a class="decrease-qty">
<img src="/catalog/view/theme/default/img/minus.png">
</a>
<?php $numberProduct = $weight_goods == 0 ? '1' : $minimum; //echo $numberProduct;?>
<input type="text" class="qty" value="<?= $product['weight_goods'] == 0 ? '1' : $product['minimum']; ?>"
data-step="<?= $product['weight_goods'] == 0 ? '1' : $product['minimum']; ?>"
step="<?= $product['weight_goods'] == 0 ? '1' : $product['minimum']; ?>" />
<a class="increase-qty">
<img src="/catalog/view/theme/default/img/plus.png">
</a>
<span><?= $product['weight_goods'] == 0 ? 'шт' : 'кг'; ?></span>
<div class="clear"></div>
</div>
<div class="bottom_item">
<a data-id="<?php echo $product['product_id']; ?>" class="global-add-to-cart"><i
class="fa fa-cart-arrow-down"></i><span> В корзину</span></a>
<div class="clear"></div>
</div>
</div>
</div>
<?php } ?>
</div>
<div class="control_block">
<div class="more_row">
<div class="pagination_text more">Показано <span></span> товаров
из <?php echo $countproducts; ?></div>
<div class="pagin_block">
<?php if ($pagination != '') { ?>
<div class="pagin">
<?php if ($load_more == true) { ?>
<div class="more"><a class="load_more f_left" onclick="getNextPage(this);"
ontouchend="getNextPage(this);"><span>Показать еще <?php echo $more; ?>
товаров</span></a>
</div>
<?php echo $pagination; ?>
<?php } elseif ($pagination) { ?>
<?php echo $pagination; ?>
<?php } ?>
</div>
<?php } ?>
</div>
</div>
<div class="clear"></div>
</div>
</div>
<?php } else { ?>
<div class="col-sm-12 col-md-9 col-lg-9">
<h2 class="title_page"><?php echo $heading_title; ?></h2>
<div class="no-item">В этой категории ещё нет товаров</div>
</div>
<?php } ?>
</div>
</div>
</section>
<?php } ?>
<?php echo $footer; ?>
Айфон мало держит заряд, разбираемся с проблемой вместе с AppLab
Перевод документов на английский язык: Важность и ключевые аспекты
Есть модели StickerPack и StickerМежду ними связь один ко многим