We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Search Filter

Development and Programming

kmgkid's avatar
kmgkid
50 posts
14 years ago
kmgkid's avatar kmgkid

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;
        
    }
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.