gpt4 book ai didi

php - 自定义页面 Opencart 的分页

转载 作者:行者123 更新时间:2023-11-29 16:10:07 32 4
gpt4 key购买 nike

我创建了一个新页面并尝试添加分页,一切看起来都很好且正确(显示正确的结果等),但是当我单击下一个页码时,页面上的内容没有改变仍然相同我找不到什么错误的为什么页面内容不刷新

查看:

<div class="row">
<div class="col-sm-6 text-left">{{ pagination }}</div>
<div class="col-sm-6 text-right">{{ results }}</div>
</div>

Controller :

$ftotal_orders = $this->model_sale_order->getTotalFastOrders();

if (isset($this->request->get['page'])) {
$page = $this->request->get['page'];
} else {
$page = 1;
}

$url = '';

if ($order == 'ASC') {
$url .= '&order=DESC';
} else {
$url .= '&order=ASC';
}

if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}

$pagination = new Pagination();
$pagination->total = $ftotal_orders;
$pagination->page = $page;
$pagination->limit = $this->config->get('config_limit_admin');
$pagination->url = $this->url->link('sale/FastOrder', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}', true);

$data['pagination'] = $pagination->render();
$data['results'] = sprintf($this->language->get('text_pagination'), ($ftotal_orders) ? (($page - 1) * $this->config->get('config_limit_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_limit_admin')) > ($ftotal_orders - $this->config->get('config_limit_admin'))) ? $ftotal_orders : ((($page - 1) * $this->config->get('config_limit_admin')) + $this->config->get('config_limit_admin')), $ftotal_orders, ceil($ftotal_orders / $this->config->get('config_limit_admin')));

型号:

public function getTotalFastOrders() {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "fast_order");

return $query->row['total'];
}

最佳答案

尝试在 Controller 文件中遵循此代码。我认为您在检索数据时缺少 $filter_data 变量。将您的代码与此类别代码进行比较。

    if (isset($this->request->get['page'])) {
$page = $this->request->get['page'];
} else {
$page = 1;
}

$url = '';

if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}


$filter_data = array(
'start' => ($page - 1) * $this->config->get('config_limit_admin'),
'limit' => $this->config->get('config_limit_admin')
);

$category_total = $this->model_catalog_category->getTotalCategories();

$results = $this->model_catalog_category->getCategories($filter_data);

$url = '';

if ($order == 'ASC') {
$url .= '&order=DESC';
} else {
$url .= '&order=ASC';
}

if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}


$pagination = new Pagination();
$pagination->total = $category_total;
$pagination->page = $page;
$pagination->limit = $this->config->get('config_limit_admin');
$pagination->url = $this->url->link('catalog/category', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}', true);

$data['pagination'] = $pagination->render();

$data['results'] = sprintf($this->language->get('text_pagination'), ($category_total) ? (($page - 1) * $this->config->get('config_limit_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_limit_admin')) > ($category_total - $this->config->get('config_limit_admin'))) ? $category_total : ((($page - 1) * $this->config->get('config_limit_admin')) + $this->config->get('config_limit_admin')), $category_total, ceil($category_total / $this->config->get('config_limit_admin')));

关于php - 自定义页面 Opencart 的分页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55334529/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com