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);
}Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.