forked from OrchardCMS/OrchardDoc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Search.cshtml
35 lines (35 loc) · 1.31 KB
/
Search.cshtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
@using App_Code
@{
var q = Request.QueryString["q"];
var page = int.Parse(Request.QueryString["p"] ?? "1");
Page.Title = "Orchard Documentation - Search - " + q;
var resultSet = SearchHelpers.Query(HttpContext.Current, q, page);
var documents = resultSet.Documents;
if (resultSet.TotalCount == 0) {
@:No results found.
}
else {
<div class="searchResultCount">@resultSet.TotalCount @(resultSet.TotalCount > 1 ? "documents" : "document") found.</div>
<ul id="SearchResultsDiv">
@foreach (var doc in documents) {
<li>
<article>
<header>
<h2><a href="@Href(doc.Url)">@doc.Title</a></h2>
</header>
<blockquote>@Html.Raw(doc.Summary)</blockquote>
<div><a href="@Href(doc.Url)">Read more...</a></div>
</article>
</li>
}
</ul>
if (resultSet.TotalCount > SearchHelpers.PageSize) {
int pages = (resultSet.TotalCount / SearchHelpers.PageSize) + 1;
<ul class="searchPagination">
@for (var p = 1; p <= pages; p++) {
<li>@if (p == page) {<text>@p</text>} else {<a href="?q=@(q)&p=@p">@p</a>}</li>
}
</ul>
}
}
}