3 of 3
3
Plugin: Search Fields
Posted: 27 May 2010 04:53 AM   [ Ignore ]   [ # 37 ]  
Lab Assistant
RankRank
Total Posts:  191
Joined  02-23-2009

Hi All. Sorry to re-post, but any thoughts as to my last two posts (above)? My site is still running out of memory whenever someone searches with either no keywords for the Title field, or very short ones (like “a”). I’m concerned that this is because it’s choking on the 500+ results returned, and that as the site grows, I’m going to be getting 500+ results for longer keyword searches. (I could add some code to force people to search for at least 3 characters, say, but that won’t help if this is the case.)

Love this plugin - it’s made some very cool stuff possible on my site - but need to fix this or find another way to do it…

Profile
 
 
Posted: 27 May 2010 03:35 PM   [ Ignore ]   [ # 38 ]  
Summer Student
Total Posts:  23
Joined  01-10-2008

Modification to the plugin, specifically Brian’s multiple weblog code:

// limit to a weblog?
        
if ($weblog !== '*')
        
{
            
// Added by Brian Litzinger
            
if(substr($delimiter$weblog))
            
{
                $weblogs 
explode($delimiter$weblog);
                
$sql_conditions "(".$sql_conditions.") AND (";
                foreach(
$weblogs as $wb)
                
{
                    $sql_conditions 
.= "wl.blog_name = '{$DB->escape_str($wb)}' OR ";
                
}
                $sql_conditions 
substr($sql_conditions0, -4);
                
$sql_conditions .= ")";
            
}
            
else
            
{
                $sql_conditions 
"(".$sql_conditions.") AND wl.blog_name = '{$DB->escape_str($weblog)}'";
            
}
        } 

Added parentheses around $sql_conditions before the weblog specifications. Otherwise with the OR operator, results were coming from all weblogs, not just the one I specified.

Separately, the default operator is actually AND, not OR.

Profile
 
 
Posted: 16 June 2010 11:55 PM   [ Ignore ]   [ # 39 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  862
Joined  03-02-2006
Mark Croxton - 16 October 2009 09:14 AM

Alternatively you can use the dynamic_parameters parameter to tell the script to grab the submitted values from the $_POST array, although you would need to duplicate the field values if you’re searching in more than one custom field for the same string.

I don’t really understand how the dynamic_parameters parameter is supposed to work. Anyone have an example they could show me?

I’m also having trouble with returning a message if no results are returned. My template looks like this so far:

{exp:search_fields weblog="weblog" search:suburb="<?php echo $_POST['suburb'] ?>" search:pcode="<?php echo $_POST['pcode'] ?>" operator="OR" parse="inward"}

        
<table>
            <
thead>
                <
tr>
                    <
th scope="col">Name</th>
                    <
th scope="col">Address</th>
                </
tr>
            </
thead>
            <
tbody>
            
{exp:weblog:entries entry_id="{search_results}" dynamic="off"}

                
<tr class="{switch="one|two"}">
                    <
th class="left" scope="row">{title}</th>
                    <
td class="left">{address}</td>
                </
tr>
            
{/exp:weblog:entries}
            
            
</tbody>        
        </
table>

        
{/exp:search_fields} 

I thought I could use a conditional on {if search_results == “”}, say there are no results, but whenever I do, the result is to always show the no results message, even when entering a query which should show results.

 Signature 

John Faulds - Freelance Web Designer | Member of EE Pro Network

Profile
 
 
Posted: 02 July 2010 02:32 PM   [ Ignore ]   [ # 40 ]  
Research Assistant
RankRankRank
Total Posts:  330
Joined  09-03-2008

Hi - EE doesn’t natively allow you to search titles, so I thought your plugin might do the trick. However, I am currently using dynamic parameters. Does your plugin support that? If so, how would that work. This is my current setup:

{exp:weblog:entries weblog="publications" dynamic_parameters="search:pub_date|search:title|search:pub_issue|search:pub_type" limit="10" paginate="bottom"

Where the dynamic parameters are passed from a previous form. Everything works except search:title, because it returns all results.

Profile
 
 
Posted: 09 July 2010 05:39 PM   [ Ignore ]   [ # 41 ]  
Summer Student
Avatar
Total Posts:  27
Joined  05-12-2009

I’m also having a hard time getting the dynamic_parameters to work. Am I missing something obvious?

Form Code:

<form action="{path='find/by-company-name'}" method="post">
<
input type="text" name="title" id="title" /><br />
<
input type="submit" value="Go!" />
</
form

Search Fields tags from find/by-company-name:

{exp:search_fields weblog="supplier-profile" dynamic_parameters="title" parse="inward"}
{exp
:weblog:entries weblog="supplier-profile" entry_id="{search_results}" dynamic="off" orderby="title" sort="asc"}
    
<tr>
    <
td><a href="{url_title_path='profiles/display'}">{title}</a></td>
    <
td>{displayed-city}</td>
    <
td>{displayed-state}</td>
    </
tr>
{/exp:weblog:entries}
{
/exp:search_fields} 

The plugin worked great with search term hard coded. Just can’t get the dynamic_parameters to pick it up!

Thanks so much for your help!

Profile
 
 
   
3 of 3
3