[eluser]spider pig[/eluser]
I have a searchable list with pagination. I have used it in CodeIgniter 1.6.3 without problems but in version 1.7 it doesn't work.
I use flashdata to store the search text between pages but it's currently is not accepting a value. It tried it using userdata and it works fine.
Anyone have an idea what I am doing wrong.
Thanks
Here's the controller:
Code:
function search_results() {
$this->main->load_settings();
$this->load->helper('form');
$pageText = $this->main->header($this->pageID);
if (!$pageText)
return;
$html->al_main_content .= $pageText;
$categories = $this->product_support_class->product_category_array();
$searchtext = $this->session->flashdata('searchtext');
if (isset($_POST['searchtext'])) {
$data->searchtext = $this->input->post('searchtext');
} elseif (isset($searchtext)) {
$data->searchtext = $this->session->flashdata('searchtext');
} else {
$data->searchtext = NULL;
}
if (isset($_POST['cat'])) {
$data->cat = $this->input->post('cat');
} else {
$data->cat = $this->uri->segment(3, 0);
}
$data->cat_list = form_dropdown('cat', $categories, $data->cat, 'class="AdvancedCategory"');
$html->al_main_content .= $this->load->view('product_support/search_form', $data, TRUE);
$html->al_main_content .= $this->product_support_class->search_results($data->searchtext, $data->cat, base_url().'product_support/search_results/'.$data->cat);
$this->load->view('content', $html);
$this->load->view('footer');
}
Here's the model:
Code:
function search_results($searchtext, $cat, $path) {
$this->load->library('pagination');
$data->al_table_rows = NULL;
$html = '<h5 style="margin: 10px 0 5px 0;">Search Results</h5>'.LF;
if ($searchtext != NULL) {
$this->session->set_flashdata('searchtext', $searchtext);
$html .= $this->session->flashdata('searchtext');
}
$sql = "select supportID from ".$this->db->dbprefix('product_support')." where supportPublish='Y'";
if ($cat > 0)
$sql .= " and supportCategory like '%|".$this->db->escape_str($cat)."|%'";
if ($searchtext != NULL)
$sql .= " and (supportProductName like '%".$this->db->escape_str($searchtext)."%' or supportText like '%".$this->db->escape_str($searchtext)."%')";
$query = $this->db->query($sql);
$config['base_url'] = $path;
$config['total_rows'] = $query->num_rows();
$config['uri_segment'] = 4;
$config['per_page'] = '20';
$config['full_tag_open'] = '<div class="pagination">Page - ';
$config['full_tag_close'] = '</div>';
$config['cur_tag_open'] = '<span>';
$config['cur_tag_close'] = '</span>';
$this->pagination->initialize($config);
$sql = "select * from ".$this->db->dbprefix('product_support')." where supportPublish='Y'";
if ($cat > 0)
$sql .= " and supportCategory like '%|".$this->db->escape_str($cat)."|%'";
if ($searchtext != NULL)
$sql .= " and (supportProductName like '%".$this->db->escape_str($searchtext)."%' or supportText like '%".$this->db->escape_str($searchtext)."%')";
$sql .= " limit ".$this->uri->segment(4, 0).",20";
$query = $this->db->query($sql);
$html .= $this->pagination->create_links();
if ($query->num_rows() > 0) {
$counter = 0;
foreach ($query->result() as $row) {
$data->al_table_rows .= '<tr'.$this->product_support_class->row_colour($counter).'><td><h5><a >supportID.'/'.htmlentities($row->supportPath).'">'.htmlentities($row->supportProductName).'</a></h5></td><td valign="top" class="textright">12/03/2008</td></tr>'.LF;
$counter++;
}
} else {
$data->al_table_rows .= '<tr><td colspan="2"><div style="text-align: center; padding: 50px 0;"><h5>No product support documents match the search criteria.</h5></div></td></tr>'.LF;
}
$html .= $this->load->view('product_support/results_table', $data, TRUE);
$html .= $this->pagination->create_links();
return $html;
}
Session settings:
Code:
$config['encryption_key'] = "password";
$config['sess_cookie_name'] = 'cisession';
$config['sess_expiration'] = 7200;
$config['sess_encrypt_cookie'] = TRUE;
$config['sess_use_database'] = FALSE;
$config['sess_table_name'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;