I’m just a beginner of codeigniter, I’ve tried to redirect to a controller page (PageController.php) by clicking a hyperlink. I may be able to redirect to that particular page but the layout of the page is not what I’ve expected. That page is the one I’ve set as the default controller in routes.php. The page is ok and in a correct format when I’m not yet clicking the hyperlink to redirect to the page. I’ve tested this in a local machine. Hope someone could help me. Thanks!
Here’s my code:
PageController.php
class PageController extends CI_Controller
{
function index(){
$this->loadPageHeader();
$this->loadMenuHeader();
$this->loadAdvertisingVideo();
$this->loadMainContent();
$this->loadSidebar();
$this->loadPageFooter();
}
function loadPageHeader(){
// Loading page header here...
}
function loadMenuHeader(){
// Loading menu headers here...
}
function loadAdvertisingVideo(){
// Load something here...
}
function loadMainContent(){
// Loading the main content of the page here...
}
function loadSidebar(){
// Loading some here...
}
function loadPageFooter(){
// Loading page footer...
}
}
Here is the hyperlink that performs the redirection to the controller page.
<a href=<?php echo site_url(‘PageController’);?>Home</a>
<a href=modules.php>Modules</a>
<a href=aboutus.php>About Us</a>
By what you show here you may want to set a route to catch all for this controller. In your config routes.php file add a line:
then in your controller index method you would parse out uri segments like so, if applicable…
URL segments are useful if you want one method to handle all requests for this controller, but may not be necessary in your case. I don’t know enough about your scenario. If I missed something and you have more questions, feel free to ask and I may update.