CodeIgniter as well as many php frameworks works with Controllers and Views, in case CI3 would look like this:
login:
<?php
class Login extends CI_Controller
{
public function index()
{
$data['page_title'] = 'Login';
$this->load->view('headerview', $data);
$this->load->view('menuview', array( 'islogin' => true ));
$this->load->view('loginview'); //isto exibe o view do login
$this->load->view('footerview');
}
}
Signing up:
<?php
class Cadastro extends CI_Controller
{
public function index()
{
$data['page_title'] = 'Cadastro';
$this->load->view('headerview', $data);
$this->load->view('menuview', array( 'islogin' => false ));
$this->load->view('cadastroview'); //isto exibe o view do cadastro
$this->load->view('footerview');
}
}
When accessing http://localhost/ci/index.php/login/
you would see the result of the login controller
When accessing http://localhost/ci/index.php/cadastro/
you would see the result of the controller register
In the view you will have to make the adjustment, see that you pass array( 'isLogin' => ... )
on both as true and false, so it should look like this:
if ($islogin) {
echo '<li>
<p class="navbar-btn">
<a href="#" class="btn btn-info">
Cadastro
</a>
</p>
</li>';
} else {
echo '<li>
<p class="navbar-btn">
<a href="#" class="btn btn-info">
Login
</a>
</p>
</li>';
}
Note that $islogin
represents array( 'isLogin' => ... )
of the controller.
For more details see the documentation:
Note that the URLs in CI3 are thus http://localhost/ci/index.php/...
if you want to "remove" index.php
you can use .htaccess like this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Documentation: