Reputation: 1049
I create a simple home page making at first the controller that point to it.Now inside the home page I have some links that point to another page.since I'm a newbie I' asking to what those link have to point?maybe to others controllers that points to another pages? If so, which could be the best way to implement those controller in the index page?
Upvotes: 0
Views: 4717
Reputation: 103
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class home extends CI_Controller {
public function __construct()
{
parent::__construct();
error_reporting(E_ALL & ~E_NOTICE);
$this->load->helper('form');
}
public function _remap()
{
$segment_1 = $this->uri->segment(1);
switch ($segment_1) {
case null:
case false:
case '':
$this->check();
break;
case 'mani':
$this->mani();
break;
default:
$this->check();
break;
}
}
public function check()
{
echo "hasgdhsad";
}
public function mani(){
echo "index";
}
}
Upvotes: 0
Reputation: 25435
Don't understand well your question, but links to other pages are controllers/methods that build those pages.
You can also use the built-in methods to build a correct url for CI. Load the URL helper
(autoload it or use $this->load->helper('url');
) and you can use:
<a href="<?php echo site_url('controller/method');?>">Link to page</a>
That (the site_url()
function) would build a correct (for CodeIgniter) link to www.yoursite.com/index.php/controller/method
.
In your controller then you'll need to create the function (method) you asked for, and load the appropriate views.
Ex: <a href="<?php echo site_url('blog/write');?>">Write an entry</a>
will map to controllers/blog.php
:
class Blog extends CI_Controller{
function write()
{
$this->load->view('write_form');
}
}
But CI's possibily the best documented framework out there, so refer to the manual and this will be soon very clear.
Upvotes: 1
Reputation: 7302
I think this page has all the answers for you: http://codeigniter.com/user_guide/helpers/url_helper.html
Upvotes: 1