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

  • Home
  • SEARCH
  • 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 9202847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:20:44+00:00 2026-06-17T23:20:44+00:00

I am creating a website using codeigniter and I want to include the menu

  • 0

I am creating a website using codeigniter and I want to include the menu (options) file so that I could save all my time from independently pasting the code on every view I need.
Or even if there is a common file for custom functions where I could place the code and call the function.
ANy help. My menu option is as follows.

 <h5>Admin Options</h5>
            <ul>
                <li><a href="">Portfolio</a>
                    <ul>
                        <li> <a href="category/addCategory">Add a Category</a></li>
                        <li> <a href="category/updateCategory">Edit/Delete Category</a></li>
                        <li> <a href="link/addLink">Add a Link</a></li>
                        <li> <a href="link/updateLink">Edit/Delete Link</a></li>
                    </ul>
                </li>

                <li>First</li>
                <li>First</li>
                <li>First</li>
                <li>First</li>

            </ul>
  • 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-06-17T23:20:45+00:00Added an answer on June 17, 2026 at 11:20 pm

    As you can see by the answers there are a number of ways of doing this but honestly I don’t see the point in a templating library as it’s relatively easy to do on your own. I use templates for my entire site since it means I don’t have to keep rewriting code. Below is how I do it.

    Template.php This file loads the other parts of the template, it loads the header dependent on whether the user is logged in so I can add the user menus easily.

        <?php 
            if($this->session->userdata('is_logged_in'))
            {
                $this->load->view('templates/header-admin', $title);
            } else {
                $this->load->view('templates/header', $title);
            }
            $this->load->view('templates/sidebar',$sidebar_content);
            $this->load->view('pages/'.$main_content);
            $this->load->view('templates/footer'); 
        ?>
    

    Each of those pages is a static html file or as in the case of the main content and sidebar_content they’re variables. So then from a controller I load my views like this (this is a basic page)

    public function welcome()
    {
        $data['main_content'] = 'welcome';
        $this->load->model('someModel');
        $data['someArray'] = $this->someModel->someFunction();
        $data['title']='Welcome to example.com';
        $data['sidebar_content'] = 'sidebar/no_sidebar';
        $data['additionalHeadInfo'] ='';
        $this->load->view('templates/template',$data);  
    }
    

    So what’s happening above is the first line is the actual view getting loaded to main content this is a php page with nothing but the middle content of the site in it. Title fills in the title tags in the header. sidebar content loads the appropriate sidebar.php page (in this case it’s an empty file). Additional head info is so I can load libraries or css pages specific to a single view. The final line brings it all together.

    Edit – I added two lines for adding variable data. So you would do a call to your model like normal and return the data, but return it to an array inside the $data array. Then in your view you would access it like this (variables are obviously for example, you’d use whatever variables your model returns:

    echo $someArray['userName'];
    

    For the record normal PHP include statements work just fine in CI, it just makes a lot less sense than creating a template.

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

Sidebar

Related Questions

I'm creating a website that people can send sms from my website, I want
I am creating a website using ASP.NET that supports multiple languages. For that I
i'm creating a shopping website that will sell computer parts using MVP and asp.net.
While creating a website using Twitter Bootstrap's carousel, it seems that some scripts are
I'm creating a website using MVC2. Where do I save the image?
I'm re-creating a registration for my website using Codeigniter. On my previous page, I
I'm looking for help/advice with creating simple JSP website using equivalent of PHP include+switch
I'm creating a website/codeigniter-project that uses views which link to external CSS files. Everywhere
I'm creating website using Ruby on rails3 with twitter-bootstrap. I downloaded bootstrap.css from official
I am creating a basic CMS website using Alfresco Web Quick Start. I want

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.