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 10:42AM
    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 10:42AM
    Thanks for the answers. That works fine adding the $CI = & get_instance(); line in at the beginning.
Sign In or Register to comment.