Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1062149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:34:47+00:00 2026-05-16T18:34:47+00:00

How would you structure the below page in Codeigniter? I thought about creating seperate

  • 0

How would you structure the below page in Codeigniter?

alt text

I thought about creating seperate controllers for each section

  1. Left nav
  2. Content nav
  3. Login name
  4. Leaderboard

Excluding the content section (as this changes depending on the link on the left nav and content nav used as a kinda sub-menu). All the other sections remain roughly the same

I thought about doing:

Class User_Profile extends Controller
{

    function index()
    {
        $this->load_controller('Left_Nav');
        $this->load_controller('Content_Nav');
        $this->load_controller('Login_Name');
        $this->load_controller('Leaderboard', 'Board');

        $this->Left_Nav->index(array('highlight_selected_page' => 'blah'));

        $this->load('User');

        $content_data = $this->User->get_profile_details();

        $this->view->load('content', $content_data);

        $this->Login_Name->index();
        $this->Board->index();
    }

}

Obviously this load_controller does not exist but this functionaility would be useful. The controller for each section gets the data required from the model and then loads the page through $this->view->load()

It could be a headache to have this code in all the left nav links like News, Users, About Us, etc.. But then again not every nav link has all those sections so I need that flexability of having the sections as a “partial view”

Can anyone suggest a better way of doing this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T18:34:48+00:00Added an answer on May 16, 2026 at 6:34 pm

    I can’t vouch that this is the best approach, but I create a base controller like this:

    class MY_Controller extends CI_Controller {
    
        public $title = '';
        // The template will use this to include default.css by default
        public $styles = array('default');
    
        function _output($content)
        {
            // Load the base template with output content available as $content
            $data['content'] = &$content;
            $this->load->view('base', $data);
        }
    
    }
    

    The view called ‘base’ is a template (a view that includes other views):

    <?php echo doctype(); ?>
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <?php $this->load->view('meta'); ?>
        </head>
        <body>
            <div id="wrapper">
                <?php $this->load->view('header'); ?>
    
                <div id="content">
                    <?php echo $content; ?>
                </div>
    
                <?php $this->load->view('footer'); ?>
            </div>
        </body>
    </html>
    

    What this achieves is that every controller wraps its output in the base template, and that views have valid HTML instead of opening tags in one view and closing in another. If I’d like a specific controller to use a different or no template, I could just override the magic _output() method.

    An actual controller would look like this:

    class Home extends MY_Controller {
    
        // Override the title
        public $title = 'Home';
    
        function __construct()
        {
            // Append a stylesheet (home.css) to the defaults
            $this->styles[] = 'home';
        }
    
        function index()
        {
            // The output of this view will be wrapped in the base template
            $this->load->view('home');
        }
    }
    

    Then I could use its properties in my views like this (this is the ‘meta’ view that populates the <head> element):

    echo "<title>{$this->title}</title>";
    foreach ($this->styles as $url)
        echo link_tag("styles/$url.css");
    

    I like my approach because it respects the DRY principle and the header, footer and other elements get included just once in the code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page with the below structure (HTML content shortened for readability), where
How would I go about resizing a div from a page to it's master
I am working on a nav menu the markup structure is below, the span
I am creating a website using the MVC structure. Below is a code I
Specifically, I have a folder structure that looks like the below: about (main folder)
The menu structure I have is given below. The necessary requirements are: Each li
I am trying to determine which implementation of the data structure would be best
I have this table structure and would like to map it using Fluent Hibernate
I'm looking for a Java built-in data structure that would be the best at
I would like to create some kind of structure to reduce the number of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.