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

Module Help: Sort by date

Development and Programming

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

The module counts the number of outbound clicks for each entry.

I having trouble posting the filterform selections and returning the results in the table.

I’m using the comments module as an example, but cant figure it out. Any help would be appreciated.

I believe the the ajax_filter is responsible for this task. please correct me if wrong.

function clicks_ajax_filter()
    {
        $this->EE->output->enable_profiler(FALSE);
        $this->EE->load->helper('text');
        //$this->EE->load->model('search_model');
        $this->EE->load->model('comment_model');
        $ids = array();
        
                
        $col_map = array('entry_id', 'title', 'totalclicks');

        // Note- we pipeline the js, so pull more data than are displayed on the page        
        $perpage = $this->EE->input->get_post('iDisplayLength');
        $offset = ($this->EE->input->get_post('iDisplayStart')) ? $this->EE->input->get_post('iDisplayStart') : 0; // Display start point
        $sEcho = $this->EE->input->get_post('sEcho');

        
        /* Ordering */
        $order = array();
        
        if ($this->EE->input->get('iSortCol_0') !== FALSE)
        {
            for ( $i=0; $i < $this->EE->input->get('iSortingCols'); $i++ )
            {
                if (isset($col_map[$this->EE->input->get('iSortCol_'.$i)]))
                {
                    $order[$col_map[$this->EE->input->get('iSortCol_'.$i)]] = ($this->EE->input->get('sSortDir_'.$i) == 'asc') ? 'asc' : 'desc';
                }
            }
        }

        $filter = $this->filter_settings($ajax = TRUE);
        
        //  Get clicks
                $this->EE->db->select('t.entry_id, t.title, COUNT(icc.click_id) as total_clicks');
        $this->EE->db->from('channel_titles as t');
        $this->EE->db->join('im_clicktracker_clicks as icc', 'icc.entry_id = t.entry_id','left');
        //$this->EE->db->join('categories as cat', 'cat.cat_id = icc.cat_id','left');
        $this->EE->db->where('t.channel_id');
        $this->EE->db->group_by('t.entry_id');
        //$this->EE->db->limit(10);
        $click_query = $this->EE->db->get($filter, '', $order);  
        
        $clicks =  array_slice($click_query->result_array(), $offset, $perpage);
        
    
        
        foreach ($clicks as $id)
        {
            $ids[] = $id['entry_id'];
        }
        
        $this->EE->db->where('site_id', $this->EE->config->item('site_id'));
        $total = $this->EE->db->count_all_results('channel_titles');
        
        

        $j_response['sEcho'] = $sEcho;
        $j_response['iTotalRecords'] = $total;
        $j_response['iTotalDisplayRecords'] = $click_query->num_rows();
                    
        $tdata = array();
        $i = 0;            
        
        $click_results = $this->EE->comment_model->fetch_comment_data($ids, $order);
    
    
        $j_response['aaData'] = $tdata;    
        $sOutput = $this->EE->javascript->generate_json($j_response, TRUE);
    
        die($sOutput);
    }
       

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.