[eluser]debow[/eluser]
I'm trying to display photos from a selected photo album and I'm having issues getting the pagination working. On one page/view I have listed all the photo albums created. Each has a link that has the id tied to it that takes you into the page/view of photos associated to that album. The photos will display based off the per_page I choose and so do the pages links but when I choose page 2 page 3 etc nothing happens. I'm not sure if its the call back to the ajax function since the id is somewhat dynamic or what the issue is. Below is the code.
[controller] When I click on the album I want to view it passes the id to this function
Code:
function gallery_view_test($id){
$data['gid'] = $id;
$this->load->view('includes/header', $this->data);
$data['main_content'] = 'gallery/test/gallery_view_test';
$this->load->view('includes/template', $data);
//$this->ajax_get_gallery_full($gid);
}
function ajax_get_gallery_full_test($id = null){
$id = $_POST['id'];
$data['image'] = base_url() . 'uploads/';
$start_row = $this->uri->segment(4);
$per_page = 1;
if (trim($start_row) == '') {
$start_row = 0;
}
$data['rows'] = $this->gallery_tbl->viewCategories_gallery_test($id);//Gets the description for the gallery tbl=gallery_categories
$data['query'] = $this->gallery_tbl->test($id);//Gets the data from the gallery tbl=gallery_assets
$total_rows= $data['query']->num_rows();
$this->load->library('pagination');
$config['base_url'] = base_url() . 'test/ajax_get_gallery_full_test/';
$config['total_rows'] = $total_rows;
$config['per_page'] = $per_page;
$config['full_tag_open'] = '<p class="gallery_pagination">';
$config['full_tag_close'] = '</p>';
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$data['query'] = $this->gallery_tbl->test_limited($start_row,$per_page,$id);//Gets the data from the gallery tbl=gallery_assets
$this->session->set_userdata('table_start_row', $start_row);
$_html = $this->load->view('gallery/test/gallery_full_table_test', $data, TRUE);
echo $_html;
}
[model]
Code:
function test($id){
$query_str = "SELECT * from gallery_assets where cat_id = $id";
$result = $this->db->query($query_str);
return $result;
}
function test_limited($start_row,$limit,$id){
echo $start_row; echo " start row"; echo "<br/>";
echo $limit; echo " limit"; echo "<br/>";
echo $id; echo " id"; echo "<br/>";
$query_str = "SELECT * from gallery_assets where cat_id = $id limit $start_row, $limit";
$result = $this->db->query($query_str);
return $result;
}
[view] This is the main view showing only the important code
Code:
<div id="gallery_table"></div><!-- Ajax Table-->
[removed]
$(document).ready(function(){
var gid = $('#gid').val();
$.post("<?php echo base_url(); ?>test/ajax_get_gallery_full_test/<?php echo $this->session->userdata('table_start_row');?>",{'id':<?php echo $gid;?>}, function(data) {
$("div#gallery_table").html(data);
});
$("p.gallery_pagination a").live("click", function(){
var this_url = $(this).attr("href");
$.post(this_url, { }, function(data) {
$("div#gallery_table").html(data);
});
return false;
});
});
[removed]
[view] This is where the table is created
Code:
<div class="header-title">
<!--<?php echo $test;?>-->
<?php foreach ($rows as $r): ?>
<span class="page-desc"><?php echo $r->description; ?></span>
<?php endforeach; ?>
</div>
<div id="gallery">
<ul class="portfolio">
<?php foreach ($query->result() as $r): ?>
<li class="">
<a class="image-wrap">filename;?>" rel="prettyPhoto[gallery]" title="<?php echo $r->caption; ?>"><img width="300" height="300">filename; ?>" class="attachment-portfolio-post-thumbnail wp-post-image" alt="<?php echo $r->caption ?>" title="<?php echo $r->caption ?>" /><span class="zoom-icon"></span></a>
<div class="folio-desc">
<p class="excerpt"><?php echo $r->caption; ?> </p>
</div>
</li>
<?php endforeach; ?>
</ul>
<div class="clear"></div>
</div>
<div id="wp-pagenavi" align='center'>
<?php if (strlen($pagination)): ?>
Pages:<?php echo $pagination ?>
<?php endif ?><!-- Page navigation -->
</tr>
</div>