CodeIgniter Forums
Dashboard navigation problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: General (https://forum.codeigniter.com/forum-1.html)
+--- Forum: Lounge (https://forum.codeigniter.com/forum-3.html)
+--- Thread: Dashboard navigation problem (/thread-71744.html)



Dashboard navigation problem - kvanaraj - 09-18-2018

i am having two dashboard one for user and another of Admin
In the header when i click the admin page it cannot navigate to the corresponding page.


<a href="<?php echo base_url(); ?>users/dashboard"><?php echo $this->session->userdata('username'); ?></a>

User dashboard
Code:
$data['title'] = 'Dashboard';
            $this->load->model('user_model');          
     $data['appdetails_show'] = $this->user_model->getapp();    


            $this->load->view('templates/header');
            $this->load->view('user/dashboard', $data);
            $this->load->view('templates/footer');


Admin Dashboard
Code:
$data['title'] = 'Admin Dashboard';
     $this->load->model('user_model');          
     $data['appdetails_admin'] = $this->user_model->getapp_admin();    


     $this->load->view('templates/header');
     $this->load->view('users/admin_dashboard', $data);
     $this->load->view('templates/footer');


how to redirect ?


RE: Dashboard navigation problem - Pertti - 09-18-2018

You can either have two different controllers, and do
Code:
<a href="<?php echo site_url($isAdmin === true? 'admin/dashboard' : 'users/dashboard') ?>">...

Or you could have single controller, link to users/dashboard, but then do
PHP Code:
$this->load->model('user_model');

$this->load->view('templates/header');

if (
$isAdmin === true) {
    
$data['title'] = 'Admin Dashboard';
    
$data['appdetails_admin'] = $this->user_model->getapp_admin();
    
$this->load->view('users/admin_dashboard'$data);
} else {
    
$data['title'] = 'Dashboard';
    
$data['appdetails_show'] = $this->user_model->getapp();
    
$this->load->view('user/dashboard'$data);
}

$this->load->view('templates/footer'); 



RE: Dashboard navigation problem - Wouter60 - 09-18-2018

I've shown you several times that CI has a helper function called anchor().

Instead of:
PHP Code:
<a href="<?php echo base_url(); ?>users/dashboard"><?php echo $this->session->userdata('username'); ?></a> 

Do this:
PHP Code:
<?= anchor('users/dashboard'$this->session->username);?>



RE: Dashboard navigation problem - kvanaraj - 09-19-2018

(09-18-2018, 11:02 AM)Wouter60 Wrote: I've shown you several times that CI has a helper function called anchor().

Instead of:
PHP Code:
<a href="<?php echo base_url(); ?>users/dashboard"><?php echo $this->session->userdata('username'); ?></a> 

Do this:
PHP Code:
<?= anchor('users/dashboard'$this->session->username);?>

after upload my files into server this anchor tag not working. what to do?


RE: Dashboard navigation problem - Wouter60 - 09-19-2018

What is your $config['base_url'] setting in application/config/config.php?


RE: Dashboard navigation problem - kvanaraj - 09-19-2018

(09-19-2018, 08:37 AM)Wouter60 Wrote: What is your $config['base_url'] setting in application/config/config.php?

Code:
$base  = "http://".$_SERVER['HTTP_HOST'];
$base .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['base_url'] = $base;
$config['site_url'] = $base;


or

$config['base_url'] = 'http://127.0.0.1/project1/';


RE: Dashboard navigation problem - InsiteFX - 09-20-2018

And why are you posting this in the Forum Lounge?

This should be posted in the General Help section of the Forum.