Welcome Guest, Not a member yet? Register   Sign In
Aff... Having difficulties with Routes
#1

[eluser]Ivan Augusto[/eluser]
Hi Guys... i having problems with routes again, following the data:

Code:
// controller/projetos/projetos.php
class Projetos extends Controller {
    function Projetos() {
        parent::Controller();
        $this->load->helper('url');
        $this->load->helper('form');
    }
    function index() {
        $data['titulo'] = "Projetos";
        $data['projetos'] = $this->db->get('projetos');
        $this->load->view('projetos/projetos_view',$data);
    }
}
// controller/projetos/planejamento/planejamento.php
class Planejamento extends Controller {
    function Planejamento()    {
        parent::Controller();
        $this->load->helper('url');
        $this->load->helper('form');
    }
    function index() {
        echo 'Planejamento';
    }
    function listagem($projeto_id = 0) {
        $data['titulo'] = "Planejamentos";
        $data['projeto_id'] = $projeto_id;
        $this->load->view('projetos/planejamento/listagem_view',$data);
    }
}
// views/projetos/projetos_view.php
<html>
<head>
<title><?=$titulo;?></title>
<body>
<table border="1" width="100%">
    <thead>
        <tr>
            <th>Nome</th>
            <th>Responsável</th>
            <th>Tarefas</th>
            <th>Previsto Para</th>
            <th>&nbsp;</th>
        </tr>
    </thead>
    <tbody>
        &lt;? foreach ($projetos->result() as $projeto): ?&gt;
        <tr>
            <td>&lt;?=$projeto->nome; ?&gt;</td>
            <td>&lt;?=$projeto->gerenteProjeto_id; ?&gt;</td>
            <td>0</td>
            <td>0</td>
            <td>
                &lt;?=anchor('projetos/'.$projeto->id.'/planejamento','planejamento')?&gt;<br/
                &lt;?=anchor('projetos/'.$projeto->id.'/despesas/','despesas')?&gt;
            </td>
        </tr>            
        &lt;? endforeach; ?&gt;
    </tbody>
</table>
&lt;/body&gt;
&lt;/html&gt;

// view/projetos/planejamento/listagem_view.php
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;&lt;?=$titulo;?&gt;&lt;/title&gt;
&lt;body&gt;
&lt;?=anchor('projetos/'.$projeto_id.'/planejamento/os/adicionar','Adicionar OS');?&gt;
<br/><br/>
<table border="1" width="100%">
    <thead>
        <tr>
            <th>Nome</th>
            <th>Data Inicial</th>
            <th>Data Final</th>
            <th>Horas estimadas</th>
            <th>Horas executadas</th>
        </tr>
    </thead>
</table>
&lt;/body&gt;
&lt;/html&gt;

// and routers:
$route['projetos'] = "projetos/projetos/index";
$route['projetos/(:num)/planejamento'] = 'projetos/planejamento/planejamento/listagem/$1';

but when I click on 'Planejamento' in view, the 404 error page show up!

Pleaseee... i suffering to fix...

Thks for attention ;]~
#2

[eluser]TheFuzzy0ne[/eluser]
I'd have thought that given your controllers and methods, your route should look more like this:

Code:
$route['projetos'] = "projetos/index";
$route['projetos/(:num)/planejamento'] = 'planejamento/listagem/$1';




Theme © iAndrew 2016 - Forum software by © MyBB