4 of 4
4
Gypsy
Posted: 27 January 2010 09:52 AM   [ Ignore ]   [ # 55 ]  
Grad Student
Rank
Total Posts:  55
Joined  07-30-2009

Sorry if this is a duplicate posting of a bug, but Gypsy fields don’t seem to show up in the File Browser pop up window when uploading a file while editing a weblog entry.

The ‘Select Field’ drop down list shows all the ‘normal’ fields, but not a gypsy field.
Yes it’s easy enough to work around, but just thought you’d want to know.

Andrew

Profile
 
 
Posted: 16 February 2010 01:39 PM   [ Ignore ]   [ # 56 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  258
Joined  10-08-2002

Someone pointed out in this thread that the search module doesn’t work with Gypsy fields. Here is a dirty hack that will enable the module to properly search gypsy fields. Use at your own risk!

/system/modules/search/mod.search.php (as ships with EE 1.6.8)
Replace lines 481-506:

if ($query->num_rows 0)
            
{
                $fql 
"SELECT field_id, field_name, field_search FROM exp_weblog_fields WHERE (";

                foreach (
$query->result as $row)
                
{
                    $fql 
.= " group_id = '".$row['field_group']."' OR";    
                
}

                $fql 
substr($fql0, -2).')';  

                
$query $DB->query($fql);

                if (
$query->num_rows 0)
                
{
                    
foreach ($query->result as $row)
                    
{
                        
if ($row['field_search'== 'y')
                        
{
                            $fields[] 
$row['field_id'];
                        
}

                        $this
->fields[$row['field_name']] = array($row['field_id']$row['field_search']);
                    
}
                }
            } 

With the following:

$field_groups = array();
            
            if (
$query->num_rows 0)
            
{
                
foreach ($query->result as $row)
                
{
                    $field_groups[] 
$row['field_group'];    
                
}
            }
            
            $fql 
"SELECT field_id, field_name, field_search, group_id, field_is_gypsy, gypsy_weblogs FROM exp_weblog_fields";

            
$query $DB->query($fql);

            if (
$query->num_rows 0)
            
{
                
foreach ($query->result as $row)
                
{
                    $gypsy_weblogs 
= array();
                    
                    if (
$row['field_is_gypsy'== 'y')
                    
{
                        $gypsy_weblogs 
array_filter(explode(' '$row['gypsy_weblogs']));
                    
}
                    
                    
if ($row['field_search'== 'y' && (in_array($row['group_id']$field_groups) || array_intersect($blog_array$gypsy_weblogs) ))
                    
{
                        $fields[] 
$row['field_id'];
                    
}

                    $this
->fields[$row['field_name']] = array($row['field_id']$row['field_search']);
                
}
            } 
Profile
 
 
   
4 of 4
4