Alternative to the Codigniter table component

0

I'm developing the following screen using Codeigniter:

Mydifficultyistoleavethecodeinanelegantway,withouttheuseofthetablelibrary(IbelieveitisnotthemostsuitableforwhatIamdoing)andwithoutgreatmanipulationsofdataintheview,Iwouldlikesomesuggestionsonhowperformthisactivity.

View.php

<divid="container">
    <?php include 'menu.php';?>
    <center>
        <h1>Tarefas</h1>
    </center>
    <div id="body">
    <center>
        <?php echo form_open('tarefa/detalhes'); ?>



        <?php  $this->load->library('table');
            echo $this->table->generate();  


          echo form_close(); ?>
    <center>
    </div>
    <p class="footer">
        PGM renderizado em <strong>{elapsed_time}</strong> segundos
    </p>
</div>

Controler.php

public function index()
{
    $this->load->helper('form');
    $this->load->library('table');
    $this->load->helper('form');

    $query = $this->tarefa_model->busca_tarefa_ordenado_por_estado();

    $head = array();
    $tarefanterior ="";

    foreach ($query->result() as $row)
    {

        $data['equipeTarefas'][] = array(
                'Sequencia' => $row->sequencia,
                'Nome' => $row->nome,
                'id' => $row->id ==""?"":"#".$row->id,
                'Titulo' => $row->titulo);

        if(!in_array($row->nome,$head)){
            array_push($head,$row->nome );
        }

        $tarefa = '<figure id="containerimage">
            <input type="image"  src="'.base_url().'postit.jpeg" id="centro" name="tarefa" value="'.$row->id.'"><figcaption>#'.$row->id." ".$row->titulo.'</figcaption>
        </figure>';


        $this->table->add_row($row->sequencia== 1?"$tarefa":"", $row->sequencia== 2?$tarefa:"",$row->sequencia== 3?$tarefa:"");

    }


    $this->table->set_heading($head);

    $this->load->view('tarefa_view',$data);

}
    
asked by anonymous 02.05.2018 / 16:54

1 answer

1

You can create your own library, including extending the native CI, just create a application/libraries/MY_Table.php file:

defined('BASEPATH') OR exit('No direct script access allowed');

class MY_Table extends CI_Table {

    public function __construct() {
        parent::__construct();
    }
// defina ou sobrescreva os metodos ...

Another way, you could create a helper in a similar process.

Remembering that the prefix MY_ is defined in the file application/config.php , in the parameter $config['subclass_prefix'] = 'MY_'; I hope I have helped.

    
17.05.2018 / 18:49