Welcome Guest, Not a member yet? Register   Sign In
Pagination for CMS
#1

[eluser]Unknown[/eluser]
Hi Guys,

I am a newbie in Codeigniter and would request you Smart guys to help me out. I am creating a CMS. I have created a admin section in which we have one module with name Manage Products.

Now, when I display a list of all products that have been stored in database table, I want them to appear only 10 products at a time using pagination.

This page should be displaying in following format

Product Name | Product Price | Product Description | EDIT | DELETE

Now, using pagination i am able to display till Product Name | Product Price | Product Description. For this, I have used Pagination class with Table Class.

Now what I want is to display a fixed image for both edit and delete carrying product id so that when we click on Edit against a specifi product, it can take me to EDIT CONTROLLER.

Please make sure that I want to use these CLASSES in many more Modules in the same way with more Columns like for example, one more module called Category Management, I want following :

Category Name | Category Description | EDIT | DELETE | Active / Inactive

I WOULD REQUEST YOU GUYS TO PLEASE HELP ME OUT WITH THIS.
#2

[eluser]bigtony[/eluser]
You can put an image within an anchor like this:
Code:
<?php echo anchor("controller/edit/{$id}", img(array('src' => 'path/to/edit.gif', 'alt' => "Edit {$name}"))); ?>
#3

[eluser]markup2go[/eluser]
If you're using the table class then your links probably need to be in the array you pass to the generate() method. This can be done in the model.
#4

[eluser]w0bbes[/eluser]
Hey!

Im not sure how pagination would handle this but the problem with the table class and adding a edit/delete cell i solved in the following way by just adding the cells "manually".. (excuse the dutch)

Code:
$this->table->set_heading('Titel','Inhoud','Opties');
    
     $tmpl = array(
             'row_alt_start'        => '<tr style="background-color: #eee">'
     );
    
     foreach($overzicht->result() as $row ){
        
         $this->table->add_row($row->titel,$row->inhoud,'<a href="/edit/$id">bewerken</a> <a href="/delete/$id">verwijderen</a>');
        
     }
    $this->table->set_template($tmpl);
    echo $this->table->generate();

replace the $id with your db id




Theme © iAndrew 2016 - Forum software by © MyBB