Nathan Gilliatt

Can't get CustomFieldsSearch to work

Vote 0 Votes

I've tried many variations, but I can't seem to get search results from my custom fields. I've tried one-line CustomFieldsSearch value=1, I've tried with one or more CustomFieldsSearchField lines... nothing works. I'm trying to do a simple text search of pages, searching title, body and several custom fields. I have MT Pro 4.37 and SearchCustomFields 1.0.2. Any ideas?

        <form method="get" action="<$mt:CGIPath$><$mt:SearchScript$>">
            <input type="text" size="30" id="mainsearch" class="ti" name="search" value="<$mt:SearchString$>" />
            <input type="hidden" name="CustomFieldsSearch" value="1" />
            <input type="hidden" name="CustomFieldsSearchClassType" value="page" />
            <input type="hidden" name="CustomFieldsSearchField" value="country" />
            <input type="hidden" name="CustomFieldsSearchField" value="hq_city" />
            <input type="hidden" name="CustomFieldsSearchField" value="twitter_handle" />
            <input type="hidden" name="CustomFieldsSearchField" value="sma_tag" />
            <input type="hidden" name="CustomFieldsSearchField" value="url" />
<mt:If name="search_results">
            <input type="hidden" name="IncludeBlogs" value="<$mt:SearchIncludeBlogs$>" />
            <mt:Ignore>
            <!-- use these options only with MT::App::Search::Legacy -->
            <ul class="search-options">
                <li><input type="checkbox" name="CaseSearch" /> Case sensitive</li>
                <li><input type="checkbox" name="RegexSearch" /> Regex search</li>
            </ul>
            </mt:Ignore>
<mt:Else>
            <input type="hidden" name="IncludeBlogs" value="<$mt:BlogID$>" />
</mt:If>
            <input type="hidden" name="limit" value="<$mt:SearchMaxResults$>" />
            <input type="submit" accesskey="4" value="Search" id="mainsearchbutton" />
        </form>

Reported on Movable Type 4.3

10 Replies

| Add a Reply
  • Make that CustomFieldsSearch 1.0.2. I'm getting cross-eyed looking at this.

  • Hi Nathan,

    I'm using it on a project without any problem at all.

    Make sure you follow precisely the instructions from the CustomFieldsSearch plugin.

    Kind Regards,
    Mihai Bocsaru

    ----------------------------------
    Daily Movable Type Consultant

    Web Development
    Movable Type Consulting
    Six Apart Partner

    http://www.pro-it-service.com/
    ----------------------------------

    Movable Type Demo
    http://www.movabletypedemo.org/
    ----------------------------------

    Open Melody Demo
    http://www.openmelodydemo.org/

  • That's my challenge--it doesn't come with much documentation. The English site is offline (and limited, anyway), and the Japanese site doesn't quite spell out what to do.

    I unpacked the file and put it in plugins; the MT console shows the plugin as active (at the system level--nothing at the blog level).

    I've tried every combination of tags (copied from the site) that I can think of. I'm trying to apply a free-text search across the page (not entry) title, body, and 2 custom fields. Does it actually do that?

  • Inside the value attribute you shouldn't have the custom fields basenames, but the tag for that custom field.

    For instance, for "country" you should have something like "EntryDataCountry".

  • When I set up the custom fields, I edited PageDataCountry to country. You think that confused things?

  • OK, I tried changing the template tags back (PageDataCountry, etc.). Still no luck.

    All the comments I can find suggest that this plugin just works. I don't think I've changed that much from the default template, but it just doesn't work for me. Weird.

  • What is your current form coding?

    Also, can I see the URL where I could test that implementation?

    Eventually with a sample of what I should search for and what I should get...

  • The current code:

                <form method="get" action="<$mt:CGIPath$><$mt:SearchScript$>">
                <input type="hidden" name="CustomFieldsSearch" value="1" />
                <input type="hidden" name="CustomFieldsSearchClassType" value="page" />
                <input type="hidden" name="CustomFieldsSearchField" value="PageDataCountry" />
                <input type="hidden" name="CustomFieldsSearchField" value="PageDataHQCity" />
                <input type="text" size="30" id="mainsearch" class="ti" name="search" value="<$mt:SearchString$>" />
    <mt:If name="search_results">
                <input type="hidden" name="IncludeBlogs" value="<$mt:SearchIncludeBlogs$>" />
                <mt:Ignore>
                <!-- use these options only with MT::App::Search::Legacy -->
                <ul class="search-options">
                    <li><input type="checkbox" name="CaseSearch" /> Case sensitive</li>
                    <li><input type="checkbox" name="RegexSearch" /> Regex search</li>
                </ul>
                </mt:Ignore>
    <mt:Else>
                <input type="hidden" name="IncludeBlogs" value="<$mt:BlogID$>" />
    </mt:If>
                <input type="hidden" name="limit" value="<$mt:SearchMaxResults$>" />
                <input type="submit" accesskey="4" value="Search" id="mainsearchbutton" />
            </form>
    
    

    The site is here. A search for Spain should return at least one page (ASOMO, probably others).

    Regular search works; if you search for "Spanish" you'll see a page where that appears in the body. It's just not picking up the custom fields.

    I really appreciate your looking at this. It's the last thing that's keeping me from launching the site.

  • Can you test that also for an Entry?

    Try creating one of those custom fields also for an entry, update the form for the entry CF tag and test it.

    I'm wondering if this plugin works also for pages or not.

    Of course, I assume that the plugin is not disabled :)

  • Well, I tried a test entry with an EntryDataCountry field, and it still didn't work.

    Thanks for the attempt. Now I'm going to give up on the elegant solution and go with a workaround that works: copying the interesting bits from the custom fields into the Keywords field, which shows up in a regular search.

    *sigh*

Add a Reply

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

Forum Groups

1774 6167

Last Topic: Template modules by Zielun on Feb 16, 2012

86 302

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

1434 5088

Last Topic: Maintenance announcement by Nick on Feb 17, 2012

695 2912

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

174 740

Last Topic: Captcha images rendering slowly by ScottM on Feb 12, 2012

190 568

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