I am trying to link my view page to another controller.
my test_view.php page
//this page address is base_url/controller1/function1
<a href='controller1/function2'> test </a>
If i click, the page address will be base_url/controller1/function1/controller1/function2 which is not my desire.
my controller
//the first function1 is to show my test_view page
function function1 (){
$this->load->view('test_view');
}
//I can't get to this function2 with the link I used
function function2 (){
$this->load->view('funny');
}
Anyone could help me about this? Thanks a lot.
Sure–you just need to tell CodeIgniter to display the path:
One thing: This displays the absolute path of your site as defined in your config, not the relative path.
I prefer relative paths, so I like to create a universal function called
site_pathto do the same thing without the absolute URL. I include it in one of my universally loaded libraries and it looks something like this:The benefit of this is that, if I initially develop the site in a subdirectory, I can set site_path to
return "/subdirectory/$url"and then just remove the subdirectory once I launch.