misuzu/templates/home/search.twig

85 lines
3.9 KiB
Twig
Raw Normal View History

2019-04-13 18:44:41 +02:00
{% extends 'home/master.twig' %}
{% from 'macros.twig' import container_title %}
{% from '_layout/input.twig' import input_text %}
{% from 'user/macros.twig' import user_card %}
2019-04-13 18:44:41 +02:00
{% set title = search_query|length < 1 ? 'Search' : 'Looking for ' ~ search_query %}
2019-04-13 18:44:41 +02:00
{% set canonical_url = url('search-query', {'query': search_query}) %}
{% block content %}
2019-04-14 01:09:40 +02:00
<form class="search__input" method="get" action="{{ url('search-index') }}">
<div class="search__input__background"></div>
<div class="search__input__container">
{{ input_text('q', 'search__input__text', search_query, 'text', 'What are you looking for?', false, null, 1, true, true) }}
<button class="search__input__button" tabindex="2"><i class="fas fa-search fa-fw"></i></button>
</div>
</form>
2019-04-14 01:28:50 +02:00
{% if forum_topics|length > 0 or forum_posts|length > 0 or users|length > 0 or news_posts|length > 0 %}
<div class="container container--lazy">
{{ container_title('<i class="fas fa-folder fa-fw"></i> Categories') }}
{% if forum_topics|length > 0 %}<a href="#topics" class="link">Topics ({{ forum_topics|length|number_format }})</a>{% endif %}
{% if forum_posts|length > 0 %}<a href="#posts" class="link">Posts ({{ forum_posts|length|number_format }})</a>{% endif %}
{% if users|length > 0 %}<a href="#users" class="link">Users ({{ users|length|number_format }})</a>{% endif %}
{% if news_posts|length > 0 %}<a href="#news" class="link">News ({{ news_posts|length|number_format }})</a>{% endif %}
</div>
{% elseif search_query|length > 0 %}
<div class="container container--lazy">
{{ container_title('<i class="fas fa-search-minus fa-fw"></i> Nothing found!') }}
<div class="container__content">
No results found using that query, try something else!
</div>
</div>
{% endif %}
2019-04-13 18:44:41 +02:00
2019-04-14 01:28:50 +02:00
{% if forum_topics|length > 0 %}
2019-04-13 18:44:41 +02:00
<div id="topics" class="container container--lazy">
2019-04-14 01:28:50 +02:00
{{ container_title('<i class="fas fa-comments fa-fw"></i> Topics (%s)'|format(forum_topics|length|number_format)) }}
2019-04-13 18:44:41 +02:00
{% for topic in forum_topics %}
<a href="{{ url('forum-topic', {'topic': topic.topic_id}) }}" class="link">
{{ topic.topic_title }}
</a><br>
{% endfor %}
</div>
2019-04-14 01:28:50 +02:00
{% endif %}
2019-04-13 18:44:41 +02:00
2019-04-14 01:28:50 +02:00
{% if forum_posts|length > 0 %}
2019-04-13 18:44:41 +02:00
<div id="posts" class="container container--lazy">
2019-04-14 01:28:50 +02:00
{{ container_title('<i class="fas fa-comment fa-fw"></i> Posts (%s)'|format(forum_posts|length|number_format)) }}
2019-04-13 18:44:41 +02:00
{% for post in forum_posts %}
<a href="{{ url('forum-post', {'post': post.post_id, 'post_fragment': 'p' ~ post.post_id}) }}" class="link">
Reply by {{ post.username }} in "{{ post.topic_title }}"
</a><br>
{% endfor %}
</div>
2019-04-14 01:28:50 +02:00
{% endif %}
2019-04-13 18:44:41 +02:00
2019-04-14 01:28:50 +02:00
{% if users|length > 0 %}
2019-04-13 18:44:41 +02:00
<div id="users" class="container container--lazy">
2019-04-14 01:28:50 +02:00
{{ container_title('<i class="fas fa-users fa-fw"></i> Users (%s)'|format(users|length|number_format)) }}
<div class="userlist">
{% for user in users %}
<div class="userlist__item">
{{ user_card(user) }}
</div>
{% endfor %}
</div>
2019-04-13 18:44:41 +02:00
</div>
2019-04-14 01:28:50 +02:00
{% endif %}
2019-04-13 18:44:41 +02:00
2019-04-14 01:28:50 +02:00
{% if news_posts|length > 0 %}
2019-04-13 18:44:41 +02:00
<div id="news" class="container container--lazy">
2019-04-14 01:28:50 +02:00
{{ container_title('<i class="fas fa-newspaper fa-fw"></i> News (%s)'|format(news_posts|length|number_format)) }}
2019-04-13 18:44:41 +02:00
{% for post in news_posts %}
<a href="{{ url('news-post', {'post': post.post_id}) }}" class="link">
{{ post.post_title }}
</a><br>
{% endfor %}
</div>
{% endif %}
{% endblock %}