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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:52:51+00:00 2026-05-23T16:52:51+00:00

i’m autoloading a library named as ‘render’ in my codeigniter app. the full code

  • 0

i’m autoloading a library named as ‘render’ in my codeigniter app.
the full code of the library is :

class Render extends CI_Controller {
    public function template($template, $view, $extra_css, $extra_js) {
        $data = array();
        if (isset($view)) {
            $data['view'] = $view;
        }
        if (isset($extra_css)) {
            $data['extra_css'] = $extra_css;
        }
        if (isset($extra_js)) {
            $data['extra_js'] = $extra_js;
        }
        $template = $this->load->view("templates/$template", $data, TRUE);
        echo $template;
    }

}

this library working fine but the problem is that whenever i load this library manually or by editing autoload file, i get an error when i load any model in any of my controller.

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Home::$my_model_name

Filename: controllers/home.php

Line Number: 11

here line number 10 and 11 are :

$this->load->model('my_model_name');
$this->my_model_name->my_model_method();

and i also tried to use :

$this->load->model('my_model_name', 'My_model');
$this->My_model->my_model_method();

My controller “home” code is :

class Home extends CI_Controller {
    function __construct() {
        parent::__construct();
    }
    public function index()
    {
        $this->load->model('my_model_name');
        $this->my_model_name->index();
    }
}

i tried to add a __construct() method to my library but still no luck.

  • 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-23T16:52:51+00:00Added an answer on May 23, 2026 at 4:52 pm

    By doing

    class Render extends CI_Controller
    

    you’re not creating a library, but a controller! In order to create a library, just create the class and put it into the libraries folder.

    Inside your library, if you want to use CI’s loader to load models, for ex., you need to instantiate the main CI class.

    $CI = & get_instance();
    

    Something like (file application/libraries/render.php) :

        class Render {
    
          var $CI;
    
          function __construct()
          {
            $this->CI = &get_instance();
          }
    
           public function template($template, $view, $extra_css, $extra_js) {
            $data = array();
            if (isset($view)) {
                $data['view'] = $view;
            }
            if (isset($extra_css)) {
                $data['extra_css'] = $extra_css;
            }
            if (isset($extra_js)) {
                $data['extra_js'] = $extra_js;
            }
            $template = $this->CI->load->view("templates/$template", $data, TRUE);
            return $template;
        }
    }
    

    Then you can $CI->load everything you want inside your library, models, other libraries, whatever.
    See Utilize CI resource within your library for a thorough explanation of that. The, you call your library the usual way, $this->load->library('render') and then $this->render->whatever();

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am writing an app with both english and french support. The app requests
I am using Paperclip to handle profile photo uploads in my app. They upload
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.