From 2af9052f1eeb5544cd2eef0e59f95aacd6dc45a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Szab=C3=B3?= Date: Tue, 16 May 2017 00:43:57 +0200 Subject: [PATCH] Add previous and next button when editing page (#1112) * Add previous and next button when editing page * Add scss utilities * Hide prev and next button on mobile --- languages/en.yaml | 2 ++ themes/grav/scss/template.scss | 3 +++ themes/grav/scss/template/_utilities.scss | 5 +++++ themes/grav/templates/pages.html.twig | 14 ++++++++++++++ 4 files changed, 24 insertions(+) create mode 100644 themes/grav/scss/template/_utilities.scss diff --git a/languages/en.yaml b/languages/en.yaml index 7c7524d5..754722bf 100644 --- a/languages/en.yaml +++ b/languages/en.yaml @@ -30,6 +30,8 @@ PLUGIN_ADMIN: THEMES: "Themes" LOGOUT: "Logout" BACK: "Back" + NEXT: "Next" + PREVIOUS: "Previous" ADD_PAGE: "Add Page" ADD_MODULAR: "Add Modular" MOVE: "Move" diff --git a/themes/grav/scss/template.scss b/themes/grav/scss/template.scss index b774271c..f1b07808 100644 --- a/themes/grav/scss/template.scss +++ b/themes/grav/scss/template.scss @@ -26,6 +26,9 @@ // Extensions @import "template/extensions"; +// Utilities +@import "template/utilities"; + // Header @import "template/header"; diff --git a/themes/grav/scss/template/_utilities.scss b/themes/grav/scss/template/_utilities.scss new file mode 100644 index 00000000..ad8d2e6b --- /dev/null +++ b/themes/grav/scss/template/_utilities.scss @@ -0,0 +1,5 @@ +@include breakpoint(mobile-only) { + .hidden-mobile { + display: none!important; + } +} diff --git a/themes/grav/templates/pages.html.twig b/themes/grav/templates/pages.html.twig index c8e09085..84b10b1a 100644 --- a/themes/grav/templates/pages.html.twig +++ b/themes/grav/templates/pages.html.twig @@ -158,6 +158,20 @@ {{ preview_link|raw }} {{ "PLUGIN_ADMIN.BACK"|tu }} + {% set siblings = context.parent().children() %} + + {% if not siblings.isFirst(context.path) %} + {% set sib = siblings.nextSibling(context.path) %} + {% set sib_url = base_url ~ '/pages' ~ (sib.header.routes.default ?: sib.rawRoute) %} + {{ "PLUGIN_ADMIN.PREVIOUS"|tu }} + {% endif %} + + {% if not siblings.isLast(context.path) %} + {% set sib = siblings.prevSibling(context.path) %} + {% set sib_url = base_url ~ '/pages' ~ (sib.header.routes.default ?: sib.rawRoute) %} + {{ "PLUGIN_ADMIN.NEXT"|tu }} + {% endif %} + {% if exists %}