<?php foreach(range('A', 'Z')as $key=>$letter)
{
echo anchor('KitchenGuruAdminController/Admin_recipe_browse/'.$letter, ' '.$letter);
}
echo "<BR><BR>";
?>
<table cellpadding='5'>
<th>Delete</th>
<th></th>
<th>Id</th>
<th>Recipe name</th>
<th>Edit</th>
<?php if(isset($records)) : foreach($records as $recipe) : ?>
<tr>
<td><input type="checkbox" name="idsToDelete[]" value="<?=$recipe['recipeid']?>" /><td>
<td><?php echo $recipe['recipeid'] ?></td>
<td><?php echo $recipe['recipename'] ?></td>
<td><?php echo anchor('KitchenGuruAdminController/Admin_recipe_edit/'.$recipe['recipeid'], 'Click'); ?></td>
</tr>
<?php endforeach; ?>
<tr><?php echo $this->pagination->create_links(); ?></tr>
<?php else : ?>
<h5>Recipe Database Empty.</h5>
<?php endif; ?>
</table>
</br></br><input type="submit" name="delete_button" onclick="delete_alert()"value="Delete"/>
<?php form_close(); ?>
The above code is my view, nevermind the button and checkboxes, they are for deletion of rows.
I have successfully paginated my results. and created links from A-Z and send the corresponding letter as a segment.
Here is my controller for pagination browse:
function Admin_recipe_browse()
{
$character = $this->uri->segment(3);
$config['base_url'] = base_url() . 'index.php/KitchenGuruAdminController/Admin_recipe_browse';
$config['total_rows'] = $this->KitchenGuruAdminModel->browse_total_rows();
$config['per_page'] = 5;
$config['num_links'] = 10;
$config['uri_segment'] = 3;
$this->pagination->initialize($config);
$data['records'] = $this->KitchenGuruAdminModel->get_records($character,$config['per_page'], $this->uri->segment(3));
//$data['records'] = $this->KitchenGuruAdminModel->get_records($config['per_page'], $this->uri->segment(3));
$data['links'] = $this->pagination->create_links();
$this->load->view('Admin_recipe_browse', $data);
}
The code works fine, if i click A. it will only show results with A as the first character. The problem is when i click on the pagination links. It replaces the uri segment of my letter to a number($config['per_page'];
)
so when i go back to page 1 on my pagination links, it will not filter the results for the character link.
sample,
/segment1/segment2/A
this is my url after i click the links i made using foreach range.
my pagination is set to only show 5 per page, so when i click on page 2. the url becomes.
/segment1/segment2/5
Back to my question, i have thought of a solution, set my Character filter as segment(3) and the per_page as segment(4).
problem is i don't know how to customize $this->pagination->create_links();
Currently reading pagination class documentation on ellislab, although it doesnt tackle much on the create_links function. Is there any parameter i can pass to it to make it write on segment(4).