From 777ed756dcfd01845451937fb38559ee57ec44e9 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Mon, 23 Dec 2019 14:39:59 -0800 Subject: Channel: Change search results to use next and previous page buttons Because youtube doesn't give the number of search results, so previous behavior would give an error if a page number out of range was selected. --- youtube/templates/common_elements.html | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'youtube/templates/common_elements.html') diff --git a/youtube/templates/common_elements.html b/youtube/templates/common_elements.html index 7914c08..8ee0a3c 100644 --- a/youtube/templates/common_elements.html +++ b/youtube/templates/common_elements.html @@ -90,3 +90,18 @@ {% endfor %} {% endmacro %} + +{% macro next_previous_buttons(is_last_page, url, parameters_dictionary) %} + {% set current_page = parameters_dictionary.get('page', 1)|int %} + {% set parameters_dictionary = parameters_dictionary.to_dict() %} + + {% if current_page != 1 %} + {% set _ = parameters_dictionary.__setitem__('page', current_page - 1) %} + Previous page + {% endif %} + + {% if not is_last_page %} + {% set _ = parameters_dictionary.__setitem__('page', current_page + 1) %} + Next page + {% endif %} +{% endmacro %} -- cgit v1.2.3