From aea03db8e4e73aab1207a9318bbad4503926d709 Mon Sep 17 00:00:00 2001 From: flashwave Date: Sun, 14 Apr 2019 01:28:50 +0200 Subject: [PATCH] Hide sections individually. --- templates/home/search.twig | 40 ++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/templates/home/search.twig b/templates/home/search.twig index 3f30b462..5b6d111f 100644 --- a/templates/home/search.twig +++ b/templates/home/search.twig @@ -15,26 +15,38 @@ -
- {{ container_title('Categories') }} - Topics ({{ forum_topics|length|number_format }}) - Posts ({{ forum_posts|length|number_format }}) - Users ({{ users|length|number_format }}) - News ({{ news_posts|length|number_format }}) -
+ {% if forum_topics|length > 0 or forum_posts|length > 0 or users|length > 0 or news_posts|length > 0 %} +
+ {{ container_title(' Categories') }} + {% if forum_topics|length > 0 %}Topics ({{ forum_topics|length|number_format }}){% endif %} + {% if forum_posts|length > 0 %}Posts ({{ forum_posts|length|number_format }}){% endif %} + {% if users|length > 0 %}Users ({{ users|length|number_format }}){% endif %} + {% if news_posts|length > 0 %}News ({{ news_posts|length|number_format }}){% endif %} +
+ {% elseif search_query|length > 0 %} +
+ {{ container_title(' Nothing found!') }} - {% if search_query|length > 0 %} +
+ No results found using that query, try something else! +
+
+ {% endif %} + + {% if forum_topics|length > 0 %}
- {{ container_title('Topics (%s)'|format(forum_topics|length|number_format)) }} + {{ container_title(' Topics (%s)'|format(forum_topics|length|number_format)) }} {% for topic in forum_topics %} {{ topic.topic_title }}
{% endfor %}
+ {% endif %} + {% if forum_posts|length > 0 %}
- {{ container_title('Posts (%s)'|format(forum_posts|length|number_format)) }} + {{ container_title(' Posts (%s)'|format(forum_posts|length|number_format)) }} {% for post in forum_posts %} @@ -42,9 +54,11 @@
{% endfor %}
+ {% endif %} + {% if users|length > 0 %}
- {{ container_title('Users (%s)'|format(users|length|number_format)) }} + {{ container_title(' Users (%s)'|format(users|length|number_format)) }}
{% for user in users %} @@ -54,9 +68,11 @@ {% endfor %}
+ {% endif %} + {% if news_posts|length > 0 %}
- {{ container_title('News (%s)'|format(news_posts|length|number_format)) }} + {{ container_title(' News (%s)'|format(news_posts|length|number_format)) }} {% for post in news_posts %} {{ post.post_title }}