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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:14:55+00:00 2026-05-31T05:14:55+00:00

I need 3 different templates for my Codeigniter application. I had read about Themes’

  • 0

I need 3 different templates for my Codeigniter application. I had read about Themes’ library. But still I didn’t get any idea about how to add a template to Codeignier ..

I got about how to involke template in Controller .

Please help

  • 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-31T05:14:56+00:00Added an answer on May 31, 2026 at 5:14 am

    I’m using this template library, is really simple and works well for me.

    application/libraries/Template.php

    <?php
    class Template {
        var $template_data = array();
        var $use_template  = '';
    
        /**
         * Set variable for using in the template
         */
        function set($name, $value)
        {
            $this->template_data[$name] = $value;
        }
    
        /**
         * Set template name
         */
        function set_template($name)
        {
            $this->use_template = $name;
        }
    
        /**
         * Load view
         */
        function load($view = '' , $view_data = array(), $template = '', $return = FALSE)
        {
            $this->CI =& get_instance();
    
            if (empty($template)) {
                $template = $this->CI->config->item('template_master');
            }
    
            if (!empty($this->use_template)) {
                $template = $this->use_template;
            }
    
            $this->set($this->CI->config->item('data_container'), $this->CI->load->view($view, array_merge($view_data, array ('template' => $this->template_data)), true));
            return $this->CI->load->view($this->CI->config->item('template_folder') . '/' . $template, $this->template_data, $return);
        }
    }
    

    application/config/template.php

    <?php
    $config['template_master']  = 'main';
    $config['template_folder']  = 'templates';
    $config['data_container']   = 'content';
    

    application/views/templates/main.php

    Header<br />
    <?php echo $content; ?></br>
    Footer
    

    application/controllers/welcome.php

    <?php
    class Welcome extends CI_Controller
    {
        public function index()
        {
            $this->load->config('template');
            $this->load->library('template');
            $this->template->load('welcome', array('view' => 'data'));
        }
    }
    

    I usually put the config/library files on autoload, and you can use anytime $this->template->set_template(‘other_template’); to use another one 🙂

    Hope it helps.

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

Sidebar

Related Questions

I need an application to produce a PDF file using several different custom templates.
I need to read different values stored in a file one by one. So
Sometimes I need to use the same html code in different templates, like: <div
I need a double linked list in C, but it must be for different
I went through tons of questions about this subject, but still failed to find
Im looking at different jQuery templates for a big project. The application is probably
I have 54 sites that have different URLS but use the exact same codeigniter
I am building a perl cgi::application using html::template. I am using 7-8 different templates
I need to create a Word template where I can choose from different paragraphs
I'm coding an android app for parsing sms messages. I need different rules for

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.