← Back to News & Newsletter Support
gagra333324458
Trying to sort categories in descending order of the News & Newsletter component, through a query in the database using function onStart()
. But sorting doesn't work
[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 %}
gagra333324458
marc.jauvin24240 said:
Try:
ModelClass::orderBy('created_at', 'DESC')->get()
can you tell me where and how to display this request?
Last updated
1-3 of 3