In building a search filter for my module. I need Channels, Categories, Date
Channels and Date are working fine until I add the code the for Categories dropdown, then Categories is populated but Channels does not.
below is my create_filter() function.
any help would be appreciated.
function create_filter($filter)
{
// Channel selection pull-down menu
// Fetch the names of all channels and write each one in an <option> field
$custom_channels = array('5','6','8');
$this->EE->db->select('channel_title, channel_id, cat_group');
$this->EE->db->where('site_id', $this->EE->config->item('site_id'));
$this->EE->db->order_by('channel_title');
$this->EE->db->where_in('channel_id', $custom_channels);
$query = $this->EE->db->get('channels');
$vars = array(
'channel_selected' => $filter['channel_id'],
'channel_select_options' => array('' => $this->EE->lang->line('filter_by_channel'))
);
if ($query->num_rows() > 1)
{
$vars['channel_select_options']['all'] = $this->EE->lang->line('all');
}
foreach ($query->result_array() as $row)
{
$vars['channel_select_options'][$row['channel_id']] = $row['channel_title'];
}
//// Category selection pull-down menu
// Fetch the names of all categories and write each one in an <option> field
$custom_categories = array('83','84');
$this->EE->db->select('cat_name, cat_id');
$this->EE->db->where('site_id', $this->EE->config->item('site_id'));
$this->EE->db->order_by('cat_name');
$this->EE->db->where_in('cat_id', $custom_categories);
$cat_query = $this->EE->db->get('categories');
$vars = array(
'category_selected' => $filter['cat_id'],
'category_select_options' => array('' => $this->EE->lang->line('filter_by_category'))
);
if ($cat_query->num_rows() > 1)
{
$vars['category_select_options']['all'] = $this->EE->lang->line('all');
}
foreach ($cat_query->result_array() as $cat_row)
{
$vars['category_select_options'][$cat_row['cat_id']] = $cat_row['cat_id'];
}
// Date range pull-down menu
$vars['date_selected'] = $filter['date_range'];
$vars['date_select_options'][''] = $this->EE->lang->line('date_range');
$vars['date_select_options']['1'] = $this->EE->lang->line('past_day');
$vars['date_select_options']['7'] = $this->EE->lang->line('past_week');
$vars['date_select_options']['31'] = $this->EE->lang->line('past_month');
$vars['date_select_options']['91'] = $this->EE->lang->line('past_three_months');
$vars['date_select_options']['182'] = $this->EE->lang->line('past_six_months');
$vars['date_select_options']['365'] = $this->EE->lang->line('past_year');
$vars['date_select_options']['custom_date'] = $this->EE->lang->line('any_date');
$vars['search_form'] = 'C=addons_modules'.AMP.'M=show_module_cp'.AMP.'module=im_clicktracker';
$vars['search_form_hidden'] = array();
return $vars;
}Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.