NoSearch
A container tag whose contents are displayed only if there is no search performed. This tag is only recognized in search templates.
Version History
There’s a problem with this tag in version 4.2: bug 81304. The NoSearch tag is not functional and is fixed in 4.21.
Meanwhile, you can actually use the <mt:If>
, <mt:Else>
, <mt:ElseIf>
and <mt:Unless>
conditional tags to get this to work. Basically, you run <mt:If>
to test whether the search string evaluates to an empty string, i.e., whether it has a single alphanumeric character in it.
Example
<mt:if tag="searchstring" like="/\w/">
<MTSearchResults>
<MTBlogResultHeader>
<MTIfTagSearch>
<h2>Results for: <mt:searchstring></h2>
</MTIfTagSearch>
<MTIfStraightSearch>
<h2>Search Results for: <mt:searchstring></h2>
</MTIfStraightSearch>
</MTBlogResultHeader>
<ul>
<li>
<b><a href="<MT:EntryPermalink>" title="<MT:EntryTitle>"><mt:EntryTitle></a></b><br />
<mt:Entrybody />
</li>
</ul>
</MTSearchResults>
<MTNoSearchResults>
<h2>Searched for <mt:searchstring></h2>
<p>No entries were found containing <mt:searchstring></p>
</MTNoSearchResults>
<mt:else>
<MTNoSearch>
<h2>Nothing to search!</h2>
<p>You didn't say what you're looking for. Perhaps you need to find yourself first?</p>
</MTNoSearch>
</mt:if>
<mt:if tag="searchresultcount" eq="0">
<h3>Instructions</h3>
<p>By default, this search engine looks for all words in any order. To search for an exact phrase, enclose the phrase in quotes:</p>
<blockquote>
"<code>movable type</code>"
</blockquote>
<p>The search engine also supports <code><b>AND</b></code>, <code><b>OR</b></code>, and <code><b>NOT</b></code> keywords to specify boolean expressions:</p>
<blockquote>
<code>publishing <b>OR</b> personal</code>
</blockquote>
<blockquote>
<code>publishing <b>NOT</b> dynamic</code>
</blockquote>
</mt:if>
The logic is this:
- If the search string has some term in it, then:
a. show the results if any are found; or
b. show no results found for that string; - If the search string does not have a search term at all (the string is empty), fire the
<mt:NoSearch>
code chunk.
Finally, if <mt:SearchResultCount>
evaluates to zero (there are no search results; which is true whenever nothing is found and also when nothing is specified to find), display instructions.