Welcome Guest, Not a member yet? Register   Sign In
Is there a way detect the use of pagination?
#11

[eluser]Kraig[/eluser]
This is just an idea of what I've tried...i've tried it so many ways it's ridiculous. Doing it this way the page doesn't even load.
Home.php Controller:
Code:
public function __construct() {
  parent:: __construct();
  $this->load->model("upload_model");
  $this->load->model("membership_model");
  $this->load->model("news_model");
  $this->load->library('pagination');
}

function index()
{
  $this->show();

}

public function catSelector($catID, $q, $q1, $q2)
{
  $data['things'] = $this->membership_model->cat_page($catID);
  $data['fileCategory'] = $q;
  $data['user_info'] = $q1;
  $data['home_news'] = $q2;

  // Pagination!!!
  $config['base_url'] = base_url().'home/show';
  $config['total_rows'] = $this->membership_model->num_rows;
  $config['per_page'] = 5;
  $start = $this->uri->segment(3);
  if (trim($start) == '') {
   $start = 0;
  }
  
  $this->pagination->initialize($config);
  
  $data['pagination'] =  $this->pagination->create_links();
  //echo $this->membership_model->num_rows;
  $this->load->view('test', $data);
  
}

public function show()
{    
     // Grabbing Categories
  $q = $this->upload_model->category();
  
  // Grabbing topMembers info
  $q1 = $this->membership_model->user_info();
  
  // Grabbing news
  $q2 = $this->news_model->home_news();
  
  $this->load->view('includes/header');
  $this->load->view('includes/login');
  $this->load->view('includes/logo');
  $this->load->view('includes/ad');
  $this->load->view('includes/topMembers');
  $this->load->view('includes/news');
  $this->load->view('includes/content');
  $this->load->view('home');
  if ($_SERVER['REQUEST_METHOD'] == 'POST') {
   $catID = $_POST['cat'];
   $this->get_products($catID, $q, $q1, $q2);
  }
  else {
   $catID = 0;
   $this->get_products($catID, $q, $q1, $q2);
  }
  $this->load->view('includes/endContent');
  $this->load->view('includes/footer');

   }

This is home.php View:
Code:
<link href="<?php echo $this->config->item('base_url'); ?>/css/table_design.css" rel="stylesheet" type="text/css" media="screen" />
[removed][removed]
<br />
<br />
<div class="select_category">
    &lt;form&gt;
    <select id="basic-combo" name="basic-combo" size="1">
        <option  value="0">All Categories:</option>
        &lt;?php
            foreach ($fileCategory as $t)
            {
            echo '<option value="'.$t['id'].'">'.$t['name'].'</option>';
            }
        ?&gt;  
        <option value="3">Other...</option>
    </select>
    &lt;/form&gt;
</div>
[removed]
    function showUser(str) {
        if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
          xmlhttp=new XMLHttpRequest();
        }
        else {// code for IE6, IE5
          xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange=function() {
          if (xmlhttp.readyState==4 && xmlhttp.status==200) {
            document.getElementById("tars")[removed]=xmlhttp.responseText;
          }
        }
        xmlhttp.open("POST","home/show",true);
        xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
        xmlhttp.onload = table_design;
        xmlhttp.send("cat="+str);
    }
&lt;/script&gt;

&lt;span id="tars"></span>

Test.php View:
Code:
<table cellspacing="0" cellpadding="0">
        <tr>
            <th width="50%">File Name:</th>
            <th width="30%">File Size:</th>
            <th>Download Link:</th>
        </tr>
        
        &lt;?php
        $c = true;
  foreach($things as $files){
  
    if ($files['size'] >= 1000000000) {
                $files['size'] = round( ($files['size'] / 1000000000) , 2).' GB';
             }
    if ($files['size'] >= 1000000) {
     $files['size'] = round( ($files['size'] / 1000000) , 2).' MB';
    }else{
    $files['size'] = round( ($files['size'] / 1000) , 2).' KB';
    }
  
   echo '<tr'.(($c = !$c)?' class="odd"':'').">
    <td>$files[name]</td>
    <td>$files[size]</td>
    <td><a href='$files[location]'>Download</a></td>
   </tr>";
  } ?&gt;
        
     </table><br />


&lt;?php echo $pagination; ?&gt;
#12

[eluser]phpdev[/eluser]
Hi,

if(($this->input->is_ajax_request())) condition you can use

function get_products(){
$data = // get the product data considering the page for limits etc
$this->load->view('table_data',$data);
}

function show_products(){

if(($this->input->is_ajax_request()))
$this->get_products();
else
{
$this->load->view('header');
$this->get_products();
$this->load->footer('footer');
}


}




Theme © iAndrew 2016 - Forum software by © MyBB