【发布时间】:2017-02-28 23:55:31
【问题描述】:
我正在使用基于 Laravel 的 OctoberCMS。我不确定这是 10 月的问题还是 Laravel 的问题。
我使用Dynamic Scope 过滤数据库结果表单 URL 参数。
我没有使用记录列表拖放功能。
我如何paginate 结果?
编辑:
我有页码显示使用它,但单击一个不会转到下一页。
$this->page["scopeCategory"] = Gallery::applyCategory($category)->paginate(15);
以下示例返回自然类别中的图像名称列表:
网址localhost/nature
标识符/:category?latest/:page?
型号
范围
public function scopeApplyCategory($query, $category = null) {
return $query->where('category', $category);
}
页面
代码
# Get URL Category Identifer
$category = $this->param('category');
# Create Twig Variable from Scope Apply
$this->page["scopeCategory"] = Gallery::applyCategory($category)->paginate(15);
标记
<!-- Set Scope Variable -->
{% set scopeCategory = this.page.scopeCategory %}
<!-- List of Image Names filtered by Scope -->
{% for image in scopeCategory %}
{{ image.name }}
{% endfor %}
<!-- Paginate -->
{{ scopeCategory.render|raw }}
【问题讨论】:
标签: php laravel laravel-5 twig octobercms