• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dashboard navigation problem

#1
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 ?
Reply

#2
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'); 
Reply

#3
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);?>
Reply

#4
(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?
Reply

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

#6
(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/';
Reply

#7
And why are you posting this in the Forum Lounge?

This should be posted in the General Help section of the Forum.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.