I would like to differentiate my homepage with other pages as my structure is a little different from other pages but I have no clue is it to make use of public function view(). Currently I am working on 1 page which is my profile page, the link is localhost/account/profile, in this case, how do I differentiate homepage and account page? Below are my codes :
HTML
<header>
<nav></nav>
// only show slider if it's homepage
<slider></slider>
</header>
Controller
class Account extends BaseController
{
public function index()
{
echo view('templates/header');
echo view('account/profile');
echo view('templates/footer');
}
public function login()
{
echo view('templates/header');
echo view('account/login');
echo view('templates/footer');
}
public function register()
{
echo view('templates/header');
echo view('account/register');
echo view('templates/footer');
}
//--------------------------------------------------------------------
}
Routes
$routes->match(['get', 'post'], 'account/register', 'Account::register');
$routes->match(['get', 'post'], 'account/login', 'Account::login');
$routes->match(['get', 'post'], 'account/profile', 'Account::index');
Please let me know if the information I needed is insufficient. Thanks in advance guys.
Hmm... Somehow it's working using this method for me. Not sure whether this is a good way though.
<?php
$uri = service('uri');
if($uri->getSegment(1) == ''):
?>
<slider></slider>
<?php endif; ?>