php - Global data array in Codeigniter -


i have array

  $meta = array(        'meta_description' => 'lorem ipsum',        'meta_keywords' => 'this, is, a, keyword'   ); 

if have in controller method, can pass partial so: $this->template->set_partial('header', 'layouts/header', $meta) , passes fine.

i store meta tags in database, i'd ideally put in my_controller , populate array based on database values post's meta tags.

if move outside of controller method, message: undefined variable: meta error.

how can make globally available?

i think figured out.

i created new model handling meta data, insert following my_controller's construct method:

 $meta = $this->meta_data_model->get_item_meta();   $this->template->set_partial('header', 'layouts/header', $meta); 

this seems work fine, not sure if there better way of doing it.


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -