root/branches/release-34/default_templates/search_results.mtml @ 1855

Revision 1855, 7.8 kB (checked in by fumiakiy, 20 months ago)

Stopped sorting search results by blog id in multi blog search thus mix search results from multiple blogs. BugId:75781

Added SearchResultsHeader and SearchResultsFooter template tags.

Gave up on resurrecting per blog limiting of number of results.

  • Property svn:keywords set to Id Revision
Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" id="sixapart-standard">
4<head>
5    <title><$MTBlogName encode_html="1"$>: <__trans phrase="Search Results"></title>
6    <$mt:include module="<__trans phrase="HTML Head">"$>
7    <MTIgnore>Below Javascript adds ajax search capability</MTIgnore>
8    <script type="text/javascript">
9    <!--
10    <MTIfMoreResults>
11    function getXmlHttp() {
12        if ( !window.XMLHttpRequest ) {
13            window.XMLHttpRequest = function() {
14                var types = [
15                    "Microsoft.XMLHTTP",
16                    "MSXML2.XMLHTTP.5.0",
17                    "MSXML2.XMLHTTP.4.0",
18                    "MSXML2.XMLHTTP.3.0",
19                    "MSXML2.XMLHTTP"
20                ];
21
22                for ( var i = 0; i < types.length; i++ ) {
23                    try {
24                        return new ActiveXObject( types[ i ] );
25                    } catch( e ) {}
26                }
27
28                return undefined;
29            };
30        }
31        if ( window.XMLHttpRequest )
32            return new XMLHttpRequest();
33    }
34
35    function getResults(page) {
36        page = parseInt(page);
37        if (timer) window.clearTimeout(timer);
38        var xh = getXmlHttp();
39        if (!xh) return false;
40        var res = results[page];
41        if (!res) return;
42        var url = res['next_url'];
43        if (!url) return;
44
45        xh.open('GET', url + '&format=js', true);
46        xh.onreadystatechange = function() {
47            if ( xh.readyState == 4 ) {
48                if ( xh.status && ( xh.status != 200 ) ) {
49                    // error - ignore
50                } else {
51                    try {
52                        var page_results = eval("(" + xh.responseText + ")");
53                        if ( page_results['error'] == null )
54                            results[page + 1] = page_results['result'];
55                    } catch (e) {
56                    }
57                }
58            }
59        };
60        xh.send(null);
61    }
62
63    function swapContent(direction) {
64        if ( direction == undefined ) direction = 1;
65        var page_span = document.getElementById('current-page');
66        if (!page_span) return true;
67        var next_page = direction + parseInt(page_span.innerHTML);
68        var res = results[next_page];
69        if (!res) return true;
70        var content = res['content'];
71        if (!content) return true;
72        var div = document.getElementById('search-results');
73        if (!div) return true;
74        div.innerHTML = content;
75        timer = window.setTimeout("getResults(" + next_page + ")", 1*1000);
76        window.scroll(0, 0);
77        return false;
78    }
79    <MTElse><MTIfPreviousResults>
80    function swapContent(direction) {
81        return true;
82    }</MTIfPreviousResults>
83    </MTIfMoreResults>
84    //-->
85    </script>
86</head>
87<body class="mt-search-results <$MTVar name="page_layout"$>">
88<$MTBlogID setvar="blog_id">
89    <div id="container">
90        <div id="container-inner">
91
92
93            <$mt:include module="<__trans phrase="Banner Header">"$>
94
95
96            <div id="content">
97                <div id="content-inner">
98
99
100                    <div id="alpha">
101                        <div id="alpha-inner">
102
103<mt:ignore><!--
104    Below is the block to show search results.
105    This makes an independent block to support
106    Ajax-based background retrieval of the next search results.
107--></mt:ignore>
108<MTSetVarTemplate id="search_results" name="search_results"> 
109<MTSearchResults>
110    <MTSearchResultsHeader>
111                            <div id="search-results">
112                                <span id="current-page" class="hidden"><MTCurrentPage></span>
113                                <h1 id="page-title" class="search-results-header">
114        <MTIfStraightSearch>
115                                    <__trans phrase="Results matching &ldquo;[_1]&rdquo;" params="<$MTSearchString$>">
116        </MTIfStraightSearch>
117        <MTIfTagSearch>
118                                    <__trans phrase="Results tagged &ldquo;[_1]&rdquo;" params="<$MTSearchString$>">
119        </MTIfTagSearch>
120                                </h1>
121                                <div class="search-results-container autopagerize_page_element">
122    </MTSearchResultsHeader>
123                                    <$MTInclude module="<__trans phrase="Entry Summary">" show_blog="1" hide_counts="1" blog_id="$blog_id"$>
124    <MTSearchResultsFooter>
125                                </div><div class="autopagerize_insert_before"></div>
126
127    <MTIgnore><!-- Used with the ajax search capability of the new search class --></MTIgnore>
128                                <div class="content-nav">
129                                    <MTIfPreviousResults><a href="<MTPreviousLink>" rel="prev" onclick="return swapContent(-1);">&lt; <__trans phrase="Previous"></a>&nbsp;&nbsp;</MTIfPreviousResults><MTPagerBlock><MTIfCurrentPage><MTVar name="__value__"><MTElse><a href="<MTPagerLink>"><MTVar name="__value__"></a></MTIfCurrentPage><mt:unless name="__last__">&nbsp;</mt:unless></MTPagerBlock><MTIfMoreResults>&nbsp;&nbsp;<a href="<MTNextLink>" rel="next" onclick="return swapContent();"><__trans phrase="Next"> &gt;</a></MTIfMoreResults>
130                                </div>
131                            </div>
132    </MTSearchResultsFooter>
133</MTSearchResults>
134</MTSetVarTemplate>
135<mt:ignore><!-- Display search results constructed in the block above --></mt:ignore>
136<mt:var name="search_results">
137
138
139<mt:ignore><!-- Display no results message --></mt:ignore>
140<MTNoSearchResults>
141                            <h1 id="page-title" class="search-results-header">
142    <MTIfStraightSearch>
143                                <__trans phrase="Results matching &ldquo;[_1]&rdquo;" params="<$MTSearchString$>">
144    </MTIfStraightSearch>
145    <MTIfTagSearch>
146                                <__trans phrase="Results tagged &ldquo;[_1]&rdquo;" params="<$MTSearchString$>">
147    </MTIfTagSearch>
148                            </h1>
149                            <p><__trans phrase="No results found for &ldquo;[_1]&rdquo;." params="<$MTSearchString$>"></p>
150</MTNoSearchResults>
151
152
153<mt:ignore><!-- Display instructions for searching if search script was accessed without a query --></mt:ignore>
154<MTNoSearch>
155                            <h1 id="page-title" class="search-results-header"><__trans phrase="Instructions"></h1>
156                            <p><__trans phrase="By default, this search engine looks for all words in any order. To search for an exact phrase, enclose the phrase in quotes:"></p>
157                            <blockquote>
158                                <p><code>"<__trans phrase="movable type">"</code></p>
159                            </blockquote>
160                            <p><__trans phrase="The search engine also supports AND, OR, and NOT keywords to specify boolean expressions:"></p>
161                            <blockquote>
162                                <p><code><__trans phrase="personal OR publishing"></code></p>
163                                <p><code><__trans phrase="publishing NOT personal"></code></p>
164                            </blockquote>
165</MTNoSearch>
166
167<MTIgnore><!-- Used with the ajax search capability of the new search class --></MTIgnore>
168<MTIfMoreResults>
169<script type="text/javascript">
170<!--
171var div = document.getElementById('search-results');
172var results = {
173    '<MTCurrentPage>': {
174        'content': div.innerHTML,
175        'next_url': '<MTNextLink>'
176    }
177};
178var timer = window.setTimeout("getResults(" + <MTCurrentPage> + ")", 1*1000);
179//-->
180</script>
181</MTIfMoreResults>
182
183
184                        </div>
185                    </div>
186
187                    <$MTInclude module="<__trans phrase="Sidebar">"$>
188
189
190                </div>
191            </div>
192
193
194            <$mt:include module="<__trans phrase="Banner Footer">"$>
195
196
197        </div>
198    </div>
199</body>
200</html>
Note: See TracBrowser for help on using the browser.