/* For some unknown reason I can't get displayView() to work here (it redirects to home view afterwards). So here's a dirty fix which redirects directly to URL */
case 'random':
- $count = $this->store->getEntriesByViewCount($view, $this->user->getId());
- $id = rand(1,$count);
+ $id = 0;
+ while ($this->store->retrieveOneById($id,$this->user->getId()) == null) {
+ $count = $this->store->getEntriesByViewCount($view, $this->user->getId());
+ $id = rand(1,$count);
+ }
Tools::logm('get a random article');
Tools::redirect('?view=view&id=' . $id);
//$this->displayView('view', $id);