default userpic

NoSearch

Vote 0 Votes

Hello, how do you do...

I have a little problem which i want to fix if its possible..

the search results template has this 2 tags:


The first works fine, but the second one, instead of taking me to a custom screen that explain the search error result, takes me to a movabletype screen...

This is Movabletype 4.2, in the previous 4.0 version, this feature worked well
Maybe you have an idea of how to solve this issue.
Regards

8 Replies

| Add a Reply
  • Your example got chewed up. Repost without < and >?

  • ok,sorry, here goes:

    mt:NoSearchResults

    and

    mt:NoSearch

    • I just read through some of the MT code, and I think I know what the issue is here. There is a line in MT/App/Search.pm that causes mt-search.cgi to error out if it has no search query terms. It would appear that NoSearch and NoSearchResults don't really do much right now, based on what I saw in Template/ContextHandlers.pm, which is why NoSearch just craps out the moment that no terms are present.

      Looks to me like this needs to be submitted as a bug (which I'll do).

  • Thankyou for the answer Mike, is it possible to repair or delete this lines? or I need to wait until next version?

  • You can actually use the <mt:if>, <mt:else>, <elseif> and <mt:unless> conditional tags to get this to work.

    Basically, you run <mt:if> to test whether the <mt:searchstring> evaluates to an empty string, i.e., whether it has a single alphanumeric character in it. You’d do this by using a regular expression in <mt:if>, so:

    The logic is this:

    1. If the search string has some term in it, then:
      1. show the results if any are found; or
      2. show no results found for that string;
    2. 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.

    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:else>
    </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>
  • Hello Gautam, Thankyou for answer.
    I tried to apply the code, without luck, the same message appears...

    I would like to paste the SearchResults template adapted here, but I don“t know why the code is not shown properly

    maybe I could send you a file by email...

    regards

Add a Reply

If you need to share template code, replace all the "<" signs with "&lt;" or use this utility.

Forum Groups

1773 6162

Last Topic: Excluding categories from blog by kholechek on Feb 9, 2012

86 302

Last Topic: website entries by masoud on Oct 26, 2011

1429 5077

Last Topic: What apocalypse hit this community in the middle of 2011? by 75th on Feb 10, 2012

695 2910

Last Topic: Insert Image / File Fails by Russ Miller on Feb 10, 2012

84 291

Last Topic: How to have some other characters in entry basename automatically written by Afshin Haghighatnia on Dec 22, 2011

173 737

Last Topic: About the MT version stated in HTML source by Alex E. Schneider on Feb 7, 2012

190 567

Last Topic: Analytics Reporting by michael webster on Feb 5, 2012

48 210

Last Topic: An idea and also a request by Afshin Haghighatnia on Jun 29, 2011

64 246

Last Topic: jQuery in MT 5.1 still at 1.4 - why? by perlmonkey on May 25, 2011

code.sixapart.com

137 478

Last Topic: Getting a thumbnail with xpath by Peter on Mar 13, 2011

222 720

Last Topic: Custom Field for Asset Not Appearing by android on Feb 9, 2012