Skip to content

Node.js based forum software built for the modern web

closes #657

Baris Soner Usakli27a01f6c6162
diff --git a/public/templates/search.tpl b/public/templates/search.tpl
index 9bea91611c..0f2ad27a30 100644
--- a/public/templates/search.tpl
+++ b/public/templates/search.tpl
@@ -15,41 +15,54 @@
<div class="category search">
<div class="{show_results}">
- <ul id="topics-container" data-search-query="{search_query}">
<h3>[[topic:topics]]</h3>
+
+ <!-- IF topic_matches -->
+ <small>{topic_matches} result(s) matching "{search_query}"</small>
+ <!-- ENDIF topic_matches -->
<div class="alert alert-info {show_no_topics}">[[topic:no_topics_found]]</div>
- <!-- BEGIN topics -->
- <a href="../../topic/{topics.slug}" id="tid-{topics.tid}">
+
+ <ul id="topics-container" data-search-query="{search_query}">
+
+ <!-- BEGIN topics -->
<li class="category-item">
- <div>
- <div class="col-md-12 img-thumbnail">
- <div class="search-result-post">
- <img src="{topics.teaser_userpicture}" />
- <strong>{topics.teaser_username}</strong>: <span class="search-result-text">{topics.title}</span>
- </div>
+ <a href="../../topic/{topics.slug}" id="tid-{topics.tid}">
+ <div>
+ <div class="col-md-12 img-thumbnail">
+ <div class="search-result-post">
+ <img src="{topics.teaser_userpicture}" />
+ <strong>{topics.teaser_username}</strong>: <span class="search-result-text">{topics.title}</span>
+ </div>
+ </div>
</div>
- </div>
+ </a>
</li>
- </a>
- <!-- END topics -->
+ <!-- END topics -->
+ </ul>
+
<h3>Posts</h3>
+ <!-- IF post_matches -->
+ <small>{post_matches} result(s) matching "{search_query}"</small>
+ <!-- ENDIF post_matches -->
<div class="alert alert-info {show_no_posts}">No posts found!</div>
- <!-- BEGIN posts -->
- <a href="../../topic/{posts.topicSlug}#{posts.pid}" id="tid-{posts.tid}">
+
+ <ul id="topics-container" data-search-query="{search_query}">
+ <!-- BEGIN posts -->
<li class="category-item">
- <div>
- <div class="col-md-12 img-thumbnail">
- <div class="search-result-post">
- <img src="{posts.picture}" />
- <strong>{posts.username}</strong>: <span class="search-result-text">{posts.content}</span>
- </div>
+ <a href="../../topic/{posts.topicSlug}#{posts.pid}" id="tid-{posts.tid}">
+ <div>
+ <div class="col-md-12 img-thumbnail">
+ <div class="search-result-post">
+ <img src="{posts.picture}" />
+ <strong>{posts.username}</strong>: <span class="search-result-text">{posts.content}</span>
+ </div>
+ </div>
</div>
- </div>
+ </a>
</li>
- </a>
- <!-- END posts -->
+ <!-- END posts -->
</ul>
</div>
</div>
diff --git a/src/routes/api.js b/src/routes/api.js
index d1e7da2fb9..45e9514ce8 100644
--- a/src/routes/api.js
+++ b/src/routes/api.js
@@ -270,7 +270,9 @@ var path = require('path'),
show_results: '',
search_query: req.params.term,
posts: results[0],
- topics: results[1]
+ topics: results[1],
+ post_matches : results[0].length,
+ topic_matches : results[1].length
});
});
} else {