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 6148537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:17:55+00:00 2026-05-23T19:17:55+00:00

I’m new to CodeIgniter and I hope that my question will have a simple

  • 0

I’m new to CodeIgniter and I hope that my question will have a simple answer.

I have a website with a couple of menu items (menuA,menuB and menuC).
I have modeled it with one main controller, index(), menuA(), menuB() and menuC() in the controller. The called function sets a session value currentMenu and includes header, X, footer. Where X depends on the function called. The header then high lights the choosen menu.

Within menuC (Account settings in my webapp) I would like to have a different controller that controls subviews of AccountSettings/NotLoggedIn.

Logically I would like menuC() to include the header and the footer but then forward the call to a subcontroller that managed login or the sub pages.

Am I using the framwork wrong or is there a straight forward way to achieve 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-23T19:17:57+00:00Added an answer on May 23, 2026 at 7:17 pm

    I think it sounds like you’re not understanding how to apply MVC to your structure. Picture it this way:

    Controllers represent some facet of your application that users can interact with. For example, I could have an items controller that allows users to create, read, update, or delete items. All the logic for interacting with items is handled by that controller (meaning it calls the items model and renders the necessary views).

    In your case it sounds like you are building a pages controller that handles displaying the content for specific pages a user may call. So your controller could look something like this:

    class Page extends CI_Controller {
    
        public function index()
        {
            // Logic to render home page
        }
    
            public function about()
        {
            // Logic to render the about page
        }
    
        //  ... etc ...
    

    Views can get a little tricky when you’re dealing with complex sites that have overlap. One of the most useful tricks I’ve discovered along the way is using a emplating library to reduce redundancy. This is the one I use all the time: http://williamsconcepts.com/ci/codeigniter/libraries/template/reference.html . Using the template library you can easily define a layout that includes your header and footer and then just pass in a partial for the content you want to display.

    When you want to deal with logic in something like a menu, all you need to do is pass in a variable with the page name and then do some basic PHP render the menu.

    // Say we pass in a variable called $current to our view
    // $current contains the name of the current page
    // So say $current = 'About' for this example.
    
    
    $sitemenu = array(
        array('/', 'Home'),
        array('/about', 'About'),
        array('/help', 'Page 2'),
        array('/contact', 'Page 3')
    ); ?>
    <nav>
      <ul>
      <?php foreach( $sitemenu as $page) { ?>
         <?php if($current == $page[1]) { ?>
             <li class="current"><a href="<?php echo $page[0]; ?>"><?php echo $page[1]; ?></a></li>
         <?php } else { ?>
             <li><a href="<?php echo $page[0]; ?>"><?php echo $page[1]; ?></a></li>
         <?php } ?>
      <?php } ?>
      </ul>
    </nav>
    

    Hope this helps!

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small

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.