Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

Undefined variable: CI

edited September 2011 in Share
On the blog abut creating blocks it says that "the variable $CI is automatically passed to the static view file and is a reference to the CodeIgniter super object"

In my block the first thing I do is try to load a model like this

<?php $CI->load->model('people_model'); ?>

But this gives me the error "Undefined variable: CI"

Any ideas what I am doing wrong?

Thanks

Comments

  • edited September 2011
    Try putting this before you try to load the model:

    $CI = & get_instance();

    Not sure why this works, read why it did a while back, but have forgotten. Maybe someone else can refresh? Cheers.
  • edited 1:40AM
    The CI object isn't passed to blocks by default at the moment (just pages). Seems like a good idea to do that though, so look for that in a future GIT push.
  • edited 1:40AM
    Thanks for the answers. That works fine adding the $CI = & get_instance(); line in at the beginning.
Sign In or Register to comment.