From e51487f93265521cf04d8752b0554bb1f05dd189 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 22 Dec 2014 16:19:29 +0100 Subject: [PATCH] implemented ?random url --- inc/poche/Poche.class.php | 9 ++++++++- themes/baggy/home.twig | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 2a8037cc2..3c7a2c5a0 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -303,6 +303,14 @@ class Poche $this->messages->add('s', _('The tag has been successfully deleted')); Tools::redirect(); break; + /* 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); + Tools::logm('get a random article'); + Tools::redirect('?view=view&id=' . $id); + //$this->displayView('view', $id); + break; default: break; } @@ -445,7 +453,6 @@ class Poche $tpl_vars['entries'] = $this->store->getEntriesByView($view, $this->user->getId(), $this->pagination->get_limit(), $id); $tpl_vars['page_links'] = $page_links; $tpl_vars['nb_results'] = $count; - $tpl_vars['random'] = rand(1,$count); } Tools::logm('display ' . $view . ' view'); break; diff --git a/themes/baggy/home.twig b/themes/baggy/home.twig index 5068f755a..27eea422f 100755 --- a/themes/baggy/home.twig +++ b/themes/baggy/home.twig @@ -25,7 +25,7 @@ {% block pager %} {% if nb_results > 1 %}
-
{{ nb_results }} {% trans "results" %}{% if search_term is defined %} {% trans %}found for « {{ search_term }} »{% endtrans %}{% endif %} {% trans "random" %}
+ {{ page_links | raw }}
{% elseif nb_results == 1 %}