default userpic

Search KeyMatch

Vote 0 Votes

I'm finding the search results on MT4 to be a little lacking and I was hoping to set up something like a KeyMatch where if a users puts in a search string that I anticipate (e.g. "news") then I can display the page that I want them to go to above the regular search results.

I tried to do this using an MTIF statement with the tag SearchString, but it didn't seem to work. If I set


<mt:If tag="SearchString" eg="news">
Movable Type would ignore the IF statement and publish the conditional statement regardless of the search string.

any suggestions?

thanks,

Andrew

Reported on Movable Type 4.3

6 Replies

| Add a Reply
  • You misspelled the operator in the If tag.

  • oops. thanks.

  • Can you set "eq" to more than one thing?, like:

    <mt:If tag="SearchString" eq="news" or "events">
    

    obviously not exactly like that but something that will get the same result.

  • How does like work? All it says in the documentation is:

    "Tests whether the given value matches the regex pattern in the 'like' attribute."

    How, for example, can I get the if statement to be operable if user searches on "news", "News", "events", "Events", "event" or "Events"?

    thanks

    • There's not much more to say about it than that.
      If you need an actual example, it's used in a few of the snippets further down. That tag's just got too many possibilities to stick one between each argument; the page would become unusable. You'll find the mt:EntryAuthor example especially interesting.

      If it's the regular expression part that's a problem, you've got some research to do, unfortunately. This might be a good place to start.

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