Created
September 4, 2012 06:14
-
-
Save iainurquhart/3617489 to your computer and use it in GitHub Desktop.
Hack for solpace supersearch to allow global fields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// search for 'Add Gypsy Test' in mod.super_search and you'll see where they've catered for gypsy. | |
// add this method before or after that conditional | |
// ------------------------------------- | |
// Add our global fields | |
// ------------------------------------- | |
if( $this->EE->config->item('global_field_ids') ) | |
{ | |
$sql = "/* Super Search get fields */ SELECT | |
cf.field_id, | |
cf.field_name, | |
cf.field_search, | |
cf.field_type, | |
cf.field_text_direction | |
FROM exp_channel_fields cf | |
WHERE cf.site_id IN (".implode( ",", $site_ids ).") | |
AND cf.field_id IN (".implode( ",", $this->EE->config->item('global_field_ids') ).") | |
AND field_search = 'y'"; | |
$sql .= " AND cf.field_name != 'keywords'"; | |
$query = ee()->db->query( $sql ); | |
$channels = $this->data->get_channels(); | |
foreach ( $query->result_array() as $row ) | |
{ | |
// ------------------------------------- | |
// Prep $arr['all'] and $arr['searchable'] and $fmt[] | |
// ------------------------------------- | |
$arr['all'][$row['field_name']] = $row['field_id']; | |
$fmt[$row['field_name']] = $row['field_text_direction']; | |
// Handle fields with the same name across MSMs | |
if (isset($arr['searchable'][$row['field_name']])) | |
{ | |
if (!is_array($arr['searchable'][$row['field_name']])) | |
{ | |
if ($arr['searchable'][$row['field_name']] != $row['field_id']) | |
{ | |
$temp_id = $arr['searchable'][$row['field_name']]; | |
unset($arr['searchable'][$row['field_name']]); | |
$arr['searchable'][$row['field_name']][] = $temp_id; | |
$arr['searchable'][$row['field_name']][] = $row['field_id']; | |
unset($temp_id); | |
} | |
} | |
else | |
{ | |
if (!in_array($row['field_id'],$arr['searchable'][$row['field_name']])) | |
{ | |
$arr['searchable'][$row['field_name']][] = $row['field_id']; | |
} | |
} | |
} | |
else | |
{ | |
$arr['searchable'][$row['field_name']] = $row['field_id']; | |
} | |
foreach ( $channels as $id => $channel_data ) | |
{ | |
$arr[ $channels[ $id ]['channel_name'] ][$row['field_name']] = $row['field_id']; | |
$field_to_channel_map[ $row['field_id'] ][ $channels[ $id ]['channel_id'] ] = $channels[ $id ]['channel_id']; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment