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.
This commit is contained in:
James Taylor
2019-12-23 14:39:59 -08:00
parent c56fc56fa6
commit 777ed756dc
5 changed files with 83 additions and 39 deletions

View File

@@ -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) %}
<a class="page-button previous-page" href="{{ url + '?' + parameters_dictionary|urlencode }}">Previous page</a>
{% endif %}
{% if not is_last_page %}
{% set _ = parameters_dictionary.__setitem__('page', current_page + 1) %}
<a class="page-button next-page" href="{{ url + '?' + parameters_dictionary|urlencode }}">Next page</a>
{% endif %}
{% endmacro %}