Some assignments to $this->data array not 'sticking' |
I'm stuck on a problem where several assignments to the $this->data array do not seem to be happening. No errors are output, but it is as if these assignments were not made. In the view function of one of my controllers there are several assignments to this array, which work, but now I'm trying to add new functionality to the page built by this function and none of the new assignments to this array can be seen by the resulting page.
Here are several that work: $results = $this->person_model->get_profile( $slug ); if( $results ) $this->data[ 'person_data' ] = $results; $results = $this->person_model->get_photos( $user_id ); if( $results ) $this->data[ 'person_photos' ] = $results; $results = $this->person_model->get_videos( $user_id ); if( $results ) $this->data[ 'artist_videos' ] = $results; if( $anchor != -1 ) $this->data[ 'person_anchor' ] = $anchor; Here are two of the assignments that don't appear to be happening: $this->data[ 'counter1' ] = 100; $this->data[ 'allOtherInfo' ] = 'hi'; The page that is created after these statements occurs outputs the keys that are in the $this->data array using this statement: print_r( array_keys( $this->data ) ); Here is that output: Array ( [0] => headjs, [1] => person_data, [2] => 1, person_videos [3] => person_photos ) The output is messing the person_anchor, counter1 and allOtherInfo keys! Here is the view function that intern calls the render function to actually create the output, in which the $this-data array's keys are shown: Code: function view( $slug=NULL, $anchor=-1 ) {
Try using this after you set all your data and see if it works.
PHP Code: $this->load->vars($this->data); Remove the $this->data from your render view. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |