新闻和通讯组件页面中的分类类别。 OctoberCms

问题描述 投票:1回答:1

通过使用function onStart()通过数据库中的查询,尝试按新闻与通讯组件的降序对类别进行排序。但是排序不起作用

[newsCategories]
noPostsMessage = "Empty"
categoryPage = "newcategory"
==
function onStart()
{
$this['categories'] = Db::table('indikator_news_categories')
    ->orderBy('created_at', 'desc')
    ->get();
}
==
    {% for category in categories  %}
        <a class="btn btn-primary" href="{{ category.url }}">{{ category.name }}</a>
    {% endfor %}
octobercms
1个回答
0
投票

通过一些研究,我发现了这一点。

orderBy is not working in Laravel 5

因此,请尝试:

$this['categories'] = Db::table('indikator_news_categories as categories')
    ->orderBy('categories.created_at', 'desc')
    ->get();
© www.soinside.com 2019 - 2024. All rights reserved.