Matt C.
Well-known member
I've discovered a problem with an add-on I've developed. When I list entities on a page, it lists them newest to oldest on the first page only, BUT when you go to the next page, but it doesn't do that for the other pages.
You can see what I'm talking about if you visit the page on my site: https://anthemhub.net/dev-tracker/. Scroll down and go to the second page.
Here is my actionIndex on the my public controller:
You can see this part (
In my repository, I have this function, which finds the entities and orders them by the highest timestamp. Each entity has a timestamp property with their UNIX timestamp. I read on Stack Overflow that if you want to display the newest item, you need to set the order to descending.
Any help would be appreciated, thank you.
You can see what I'm talking about if you visit the page on my site: https://anthemhub.net/dev-tracker/. Scroll down and go to the second page.
Here is my actionIndex on the my public controller:
Code:
public function actionIndex(ParameterBag $params)
{
if ($params->entry_id)
{
return $this->actionEntry($params);
}
$page = $this->filterPage();
$perPage = $this->options()->ahDevEntriesPerPage;
$entries = $this->getEntryRepo()->findEntriesForList()->limitByPage($page, $perPage);
$total = $entries->total();
$devs = $this->getDevRepo()->findDevsForList();
$this->entrySaveProcess();
$viewParams = [
'entries' => $entries,
'devs' => $devs,
'page' => $page,
'perPage' => $perPage,
'total' => $total,
];
return $this->view('AH\DevTracker:DevTracker\View', 'ah_dev_tracker_index', $viewParams);
}
You can see this part (
$entries = $this->getEntryRepo()->findEntriesForList()->limitByPage($page, $perPage);
), where I get my entities and limit them by page. In my repository, I have this function, which finds the entities and orders them by the highest timestamp. Each entity has a timestamp property with their UNIX timestamp. I read on Stack Overflow that if you want to display the newest item, you need to set the order to descending.
PHP:
public function findEntriesForList()
{
return $this->finder('AH\DevTracker:Entry')->order('timestamp', 'DESC');
}
Any help would be appreciated, thank you.