Reputation: 863
<a class="navbar-brand" href="<?php echo base_url ('welcome/aboutus');?> "> About Us </a>
Here welcome is controller name and aboutus is page name. I have set autoload. If I run this then it shows "Object not Found", what's wrong with that?
Upvotes: 0
Views: 70
Reputation: 27
In CodeIgniter, it dose not work like that.
<?php base_url ('welcome/aboutus') ?>
What it means is that Welcome is the name of the controller and aboutus is the name of the function in the controller.
So when you click on the link generated by the above code, it will search for a function named aboutus in the controller file Welcome.
To load about us using your link, the controller should look like this,
<?php
class Welcome extends CI_Controller {
public function index() {}
public function aboutus() {
$this->load->view('Name of the view file');
}
} ?>
I think you should know What is MVC Framework? and How Dose it Work?.
Have a look at these::
Upvotes: 1
Reputation:
Your question is a bit hard to help you with because you have limited code to go by.
You may need to set your base url
$config['base_url'] = 'http://localhost/yourproject/';
$config['index_page'] = '';
Welcome is the controller name as you said and aboutus would be a function name
Follow the PHP Codeigniter Naming Style Guide
Welcome.php
<?php
class Welcome extends CI_Controller {
public function index() {
}
public function aboutus() {
}
}
You may need a suitable .htaccess file to remove it so can work with out index.php
application
system
.htaccess
index.php
Try with <?php echo base_url ('index.php/welcome/aboutus');?>
Upvotes: 1