From c2a54b37703766b2e5a466090a9eafe81a1d86ef Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Wed, 19 Aug 2015 14:32:06 +0200 Subject: [PATCH] Add a button to switch to a different language version of a page. Uses the switchlanguage task to which I added a redirect parameter to correctly switch the language --- classes/controller.php | 3 +-- themes/grav/templates/pages.html.twig | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/classes/controller.php b/classes/controller.php index 53d9380f..86bcac90 100644 --- a/classes/controller.php +++ b/classes/controller.php @@ -1036,13 +1036,12 @@ class AdminController protected function taskSwitchlanguage() { $language = $this->grav['uri']->param('lang'); + $redirect = $this->grav['uri']->param('redirect') ? 'pages/' . $this->grav['uri']->param('redirect') : 'pages'; if ($language) { $this->grav['session']->admin_lang = $language ?: 'en'; } - $redirect = 'pages'; - $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.SUCCESSFULLY_SWITCHED_LANGUAGE'), 'info'); $this->setRedirect($redirect); diff --git a/themes/grav/templates/pages.html.twig b/themes/grav/templates/pages.html.twig index 15b72b6e..ff89fbdf 100644 --- a/themes/grav/templates/pages.html.twig +++ b/themes/grav/templates/pages.html.twig @@ -119,6 +119,24 @@ {% endif %} + {% if admin.multilang %} +
+ + + + +
+ {% endif %} {% endif %} {% if mode == 'new' %}